I'm trying to build a program that takes from user some inputs (Name, Surname, telephone...) using scanf() and write them in a txt file. My problem is that still I'm learner so until now I have something like...
.
.
.
printf("Enter name: \t");
scanf("%s", &name);
fprintf(fp,"Name:\t");
fwrite(name,1, sizeof(name), fp);
printf("Enter surname: \t");
scanf("%s", &surname);
fprintf(fp,"\nSurname:\t");
fwrite(surname,1, sizeof(surname), fp);
fclose(fp);
.
.
.
The result prints in file just "Name: xxxxx"
What I'm doing wrong with fwrite() ?
Thank you,
toto_7


Sign In
Create Account


Back to top









