Questions tagged as 'c'

1
answer

Binary file being written incorrectly

Creating the binary file: #include <stdio.h> int main(int argc, char const *argv[]) { FILE *BIN; BIN = fopen ("BIN.bin","wb"); if (BIN!=NULL) { for (int i = 1; i <= 100; i++) { fwrite( & i,sizeof(i),1,BIN);...
asked by 21.11.2018 / 13:39
2
answers

Problems with fwrite in binary file

I'm trying to write and read an integer in a binary file with the following code: #include<stdio.h> #include<stdlib.h> #include<string.h> typedef struct{ int free_slot; }header; void main(void){ FILE *fd = fopen("te...
asked by 30.10.2017 / 17:06
1
answer

What's wrong with my code? (URI problem 1805)

I'm trying to solve the 1805 URI question:    A natural number is a non-negative integer (0, 1, 2, 3, 4, 5, ...). Your task in this problem is to calculate the sum of the natural numbers that are present in a given range [ A , B      For ex...
asked by 31.10.2017 / 16:57
2
answers

Error trying to print the return of a two-dimensional array

I'm trying to print a two-dimensional array through in a loop for only the array it's returned through a function that I've created. I'm suspecting that the error should be in it but I can not find the error #include <stdio.h> #de...
asked by 09.09.2017 / 23:21
1
answer

lvalue required as left operand of assignment - remainder of division

I have a problem making the rest of the room. You gave this error:    value required as left operand of assignment How do I resolve this? #include <stdio.h> #include <stdlib.h> int main() { int x; printf("informe o numero i...
asked by 02.04.2018 / 20:15
1
answer

How to properly use memcpy? [duplicate]

I'm trying to create a program that will have two vectors: char vetor_origem[20] = "algoritmo"; char vetor_copia[20] As you can see, in vetor_origem I have the word algorithm written, and I want to copy the string from it to vet...
asked by 19.06.2017 / 17:39
1
answer

char data type needs space after quotation marks in scanf

#include <stdio.h> #include <stdlib.h> void main(){ char elevador; int cod=0, a=0, b=0, c=0; while(cod == 0){ printf("\nElevador utilizado (a/b/c)? "); scanf("%c", &elevador); switch(elevador){ case 'a...
asked by 19.06.2017 / 05:59
1
answer

Libraries and Preprocessing in C / C ++

I've always been surprised at the syntax of #include and #define , since they differ greatly from the syntax of the rest of the language. I have found that this is due to the fact that these commands are intended for the preprocesso...
asked by 19.02.2018 / 03:05
1
answer

Function inserts does not work

I am building a linked list to store a string with the following signature in the registry: typedef struct Lista *Noticia; struct Lista { int hora; char *Texto; struct Lista *PN; }; And the following function insert: void...
asked by 19.07.2017 / 21:42
1
answer

Verify that the entry is an integer

I need a function that reads a keyboard entry and validates whether it is an integer (negative or positive). If it is, it should return the value. Otherwise, it should report that the entry is invalid for the user and ask again. The function...
asked by 26.09.2017 / 23:09