0

(c language) mistakes "FILE" and "structures"

this code receive user name & password for 6 users but there is mistakes i dont know what are they https://code.sololearn.com/cLU5uHronU06/#c

22nd Oct 2020, 9:29 AM
saso yoo
saso yoo - avatar
9 Respostas
+ 5
U haven't specified the return type for main() that is, write int main() and then return 0 at the end.
22nd Oct 2020, 9:34 AM
Alphin K Sajan
Alphin K Sajan - avatar
+ 1
The gets() function has a security vulnerability( buffer overflow), so it is preferable to use fgets() instead because it requires a second parameter which is the size of the buffer you wanted to store data in it. Additionally, you should remove the = sign between fputs and the parentheses '()'. Finally you need to specify the return type of your main function.
22nd Oct 2020, 9:41 AM
QTWizard
0
Alphin K Sajan QTWizard Still not work error: too few arguments to function 'fgets'
22nd Oct 2020, 10:11 AM
saso yoo
saso yoo - avatar
0
You need to enter 12 lines like: Name0 Pass0 Name1 Pass1 Name2 Pass2 And so on. That is because sololearn doesn't use an interactive IDE. If you are using fgets, you need to specify the size of the buffer.
22nd Oct 2020, 10:11 AM
QTWizard
0
QTWizard I want to do it with structures
22nd Oct 2020, 10:14 AM
saso yoo
saso yoo - avatar
0
saso yoo yeah i see, please follow my instructions in order to make your program works.
22nd Oct 2020, 10:16 AM
QTWizard
0
QTWizard I just found where is the problem I forgot to put "w" in fout=fopen("D:\mext.txt,"w"); Thanks everyone 🌹 why when I use fgets it is said error: too few arguments to function 'fgets'
22nd Oct 2020, 10:25 AM
saso yoo
saso yoo - avatar
22nd Oct 2020, 10:34 AM
QTWizard
0
it says no out put i fixed the code as told you but when i use fgets it says error: too few arguments to function 'fgets'
22nd Oct 2020, 10:49 AM
saso yoo
saso yoo - avatar