Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Basic C++ question in I/O Data?
Hi, i m kinda new to C++, but i m running into a problem for doing I/O data input and output. Supposely, using the if/of stream allows you to input data from a word/text document with number or word, then it will output w/e ur equation it is inside the execution file. However, when i done it in school with a Mac, it works fine. when i do it in all my window computer, the input is not what i wrote in the txt file. Instead, it took the number from" I donno where" and then plug me the output. It took the numbers like 4.342e24, 3.23e34, etc.... can anyone help? i just cant input the things correctly. at least in school, if i put the program.exe in one foulder with the txt, it took it and ran. In my home, no matter how I wrote the program, it takes the same things i mentioned above. (a source that i donno where it came from) some helps plz...
5 Answers
- 1 decade agoFavorite Answer
The numbers you referenced 4.342e24.... are just place holders. When the program creates your variable it will have something unknown in it until you put something in it.
So basically when you are reading in from the file, it isnt finding any numbers to store.
I dont know what the problem is from what you said. Post some code and I may be able to help you out more.
- 1 decade ago
It could be something to do with the endianness of the processor. If your Mac is a PowerPC (the processors Apple used before Intel), the bytes in memory are swapped.
For example:
If your input is a short int (2 bytes) and the value is 1, the first byte in memory will be 0 and the second byte will be 1. On an Intel processor, this is flipped around.
I would suggest doing a small check with 0s and 1s and looking at the individual bytes of the output to figure out if this is the problem. I dont know if this is definitely the answer but its worth a shot!
Source(s): http://en.wikipedia.org/wiki/Endianness - 1 decade ago
To use I/O stream in different computers every thing has to be the same, if it is told to search a specific file in a specific place that is the ONLY place it looks for that file. in order to use the executable you have to zip all the files exacly, not just the program. i ran into the same problem after i graduated.
- bradburyLv 45 years ago
char variety[firstnum]; //define an array inData>>variety; //examine in one! variety Print All numbers inData>>variety[count variety]; //you may desire to have already got examine in all the numbers. cout<<variety[count variety]<<" "; //this could desire to be in a for loop, Sum all numbers inData>>variety[count variety]; //you may desire to have already got examine in all the numbers. sum=sum+(variety[count variety]); // this could desire to be in a for loop. which would be sufficient to get you all started. have relaxing.
- How do you think about the answers? You can sign in to vote the answer.
- Anonymous1 decade ago
hey what s up williams