Why does this code print garbage values | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Why does this code print garbage values

can't figure out the problem https://code.sololearn.com/ckrsSHD6waUs/#cpp

11th Dec 2017, 1:43 AM
Chris
Chris - avatar
11 Answers
+ 10
https://code.sololearn.com/cvoN75D6tgwS/#cpp
11th Dec 2017, 2:30 AM
jay
jay - avatar
+ 8
Have you checked the file to see if it has any contents?
11th Dec 2017, 2:14 AM
jay
jay - avatar
+ 2
Wow so simple. Lol that was really frustrating me thanks
11th Dec 2017, 2:45 AM
Chris
Chris - avatar
+ 1
You write string length, string, score, yet read string length, score, string.
11th Dec 2017, 1:54 AM
John Wells
John Wells - avatar
+ 1
Yes Jay I see the string in text in the file but everything else is binary
11th Dec 2017, 2:16 AM
Chris
Chris - avatar
+ 1
The order does match
11th Dec 2017, 2:17 AM
Chris
Chris - avatar
+ 1
line 25 writes string length line 26 writes string contents line 28 writes score line 38 reads string length line 39 reads score line 44 reads string contents move 28 to follow 25
11th Dec 2017, 2:26 AM
John Wells
John Wells - avatar
0
Where are you trying to run it?
11th Dec 2017, 1:48 AM
John Wells
John Wells - avatar
0
I'm trying to running it on codeblocks
11th Dec 2017, 2:07 AM
Chris
Chris - avatar
0
I'm using those variables so I can read back the data from the file but it does not work
11th Dec 2017, 2:12 AM
Chris
Chris - avatar
0
Your order writing must match reading.
11th Dec 2017, 2:13 AM
John Wells
John Wells - avatar