Why code isn't working? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
11th Jan 2019, 12:17 PM
Rishab Sharma
Rishab Sharma - avatar
10 Answers
+ 2
Updated to create file and read so it runs here. https://code.sololearn.com/cHPQeQFyuXns
11th Jan 2019, 4:02 PM
John Wells
John Wells - avatar
+ 2
K 1010100(T)1001000(H)1000001(A)1001110(N)1001011(K)100000(Space)1011001(Y)1001111(O)1010101(U) Xd
11th Jan 2019, 5:06 PM
Rishab Sharma
Rishab Sharma - avatar
+ 1
This code can't run here as we don't get to have files so I assume you ran it elsewhere. Your biggest mistake is name. You don't allocate any storage for it, just a uninitialized pointer. When you read into it, you might be overwriting your code or other data variables. If you are lucky, you ran it on a system with memory protection so it crashes with an access violation error. Unlucky and your code could randomly erase your hard drive.
11th Jan 2019, 2:51 PM
John Wells
John Wells - avatar
+ 1
Ur threatening xd
11th Jan 2019, 3:42 PM
Rishab Sharma
Rishab Sharma - avatar
+ 1
Thn how to run it?
11th Jan 2019, 3:42 PM
Rishab Sharma
Rishab Sharma - avatar
+ 1
U have any link for these type of file codes ,i want to understand it ,i m still lacking in many areas of this topic 😞
11th Jan 2019, 3:44 PM
Rishab Sharma
Rishab Sharma - avatar
+ 1
Change line 9 to: char a,name[100]; to allow 100 character names. It should run on your PC or phone with compile/IDE.
11th Jan 2019, 3:48 PM
John Wells
John Wells - avatar
0
You have non-standard C++ includes so may only work with obsolete Turbo C++ on PC.
11th Jan 2019, 3:55 PM
John Wells
John Wells - avatar
0
Btw fseek(f1,-1,1); for ?
11th Jan 2019, 4:44 PM
Rishab Sharma
Rishab Sharma - avatar
0
That attempts to position to the character before the beginning of the file. Not sure what the result would be. fseek(f1,-1,3); Would be to read the last character as 3 picks the end of file.
11th Jan 2019, 4:49 PM
John Wells
John Wells - avatar