Hello ,, i need to write to opened file in w+ mode..
now the problem is that first off all i need to check first string in each line if he the same to value i want to enter , dont enter and print error
:
in another words i need to convert this input txt to data txt:
33333333 Johnny Depp center 6
44444444 Sandra Bullock guard 5
77777777 Tom Cruise captain 2
88888888 Cameron Diaz other 2
22222222 Gwyneth Paltrow alto 2
the first number is ID of person.. before i putting it to my data.txt
i need to check if ID alredy exist : how i do that?
What i am now using is this function to take line into string
char *getline(FILE *input)
{
char temp[MAX_LEN];
fgets(temp,MAX_LEN,input);
temp[strlen(temp)-1]='\0';
return strdup(temp);
}
lets say *buffer=getline(Pointer to data file)
ID=strtok(buffer," ");
strcmp(ID_original,ID)
But i have problems with it , lets say if the data file is empty and there is nothing to scan i got errors