English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

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...

2007-02-25 05:13:56 · 5 answers · asked by steak5959 3 in Computers & Internet Programming & Design

5 answers

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.

2007-02-25 11:12:18 · answer #1 · answered by rsmith985 3 · 0 0

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!

2007-02-25 06:00:26 · answer #2 · answered by diffusemenow 2 · 0 0

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.

2007-02-25 06:29:21 · answer #3 · answered by Patrick C 2 · 0 0

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]; //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.

2016-09-29 21:41:44 · answer #4 · answered by ? 4 · 0 0

hey what s up williams

2007-02-25 05:18:30 · answer #5 · answered by Anonymous · 0 0

fedest.com, questions and answers