+ 1

Help with a c code to input data to new txt file

ok so I just finished the c course and want to practice my knowledge so I tried to make a program to get input from a user and create a new file and write those inputs to the file ... the "email" part doesn't take input and of course, the whole program doesn't return 0. so I need help to fix it and pardon my mistakes because I am a total amateur and thanks for the help in advance. code : https://code.sololearn.com/cP3SzdlWjy9x/#c

20th Sep 2020, 9:42 AM
Manar Ahmed
Manar Ahmed - avatar
6 Antworten
+ 3
Use scanf instead of gets for each data input just remplace gets with scanf .Then as you use new_data.name in the fprintf do the some for other structure elements age occupation and email.no need to use pointer dptr.
20th Sep 2020, 10:24 AM
HBhZ_C
HBhZ_C - avatar
+ 4
You have to declare the structure outside main.
20th Sep 2020, 9:49 AM
HBhZ_C
HBhZ_C - avatar
+ 3
What kind of error your compiler gives you?
20th Sep 2020, 10:17 AM
HBhZ_C
HBhZ_C - avatar
+ 2
This my try in your code here welcome https://code.sololearn.com/ciyGl31R9HzL/?ref=app
20th Sep 2020, 10:35 AM
HBhZ_C
HBhZ_C - avatar
+ 1
it worked perfectly, thanks a lot ^^
20th Sep 2020, 10:32 AM
Manar Ahmed
Manar Ahmed - avatar
0
ok, I declared it outside the main - sorry for that mistake - but the program still has the same problems...
20th Sep 2020, 10:12 AM
Manar Ahmed
Manar Ahmed - avatar