Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- FILE *f;
- char line[LINE_SIZE];
- char *lines;
- int num_righe;
- f = fopen("spese.dat", "r");
- if(f == NULL) {
- f = fopen("spese.dat", "w");
- }
- while(fgets(line, LINE_SIZE, f)) {
- num_righe++;
- lines = realloc(lines, (sizeof(char)*LINE_SIZE)*num_righe);
- strcpy(lines[num_righe-1], line);
- }
- fclose(f);
- spese.c:29: warning: assignment makes integer from pointer without a cast
- spese.c:30: warning: incompatible implicit declaration of built-in function ‘strcpy’
- spese.c:30: warning: passing argument 1 of ‘strcpy’ makes pointer from integer without a cast
- FILE *f;
- char line[LINE_SIZE];
- char **lines = NULL;
- int num_righe = 0;
- f = fopen("spese.dat", "r");
- if(f == NULL) {
- f = fopen("spese.dat", "w");
- }
- while(fgets(line, LINE_SIZE, f)) {
- num_righe++;
- lines = (char**)realloc(lines, sizeof(char*)*num_righe);
- lines[num_righe-1] = strdup(line);
- }
- fclose(f);
- char * strcpy ( char * destination, const char * source );
- strcpy(lines[num_righe-1], line);
- strcpy(lines + (num_righe-1), line);
- lines = realloc(lines, (sizeof(char)*LINE_SIZE)*num_righe);
- if (!lines) //MUST HANDLE NULL POINTER!!
- /* string copy code here*/
- fscanf(f, "%sn", line[index]);
- index++;
Add Comment
Please, Sign In to add comment