array question

Started by
13 comments, last by omegasyphon 22 years, 6 months ago
well i have it defined as

int ary[12]={0};
Advertisement
That definition sets the first element of ary to 0.

This code works for me:
  #include <fstream.h>ifstream file;int ary[12];int main(int argc, char *argv[]){	file.open("numbers.txt");	for(int i = 0; i < 12; ++i)		file >> ary[i];	for(int j = 0; j < 12; ++j)		cout << ary[j] << endl;	return 0;}  
quote:Original post by Oluseyi

--quote--
Original post by ncsu121978
do you realize that the piece of code you have there would require you to input 4000 values ?
--/quote--

Um, 1003.

Actually 4000. The loop is from 0 to 999 (inclusive), and in each iteration 4 values are read. (Only 1003 of them would be stored in the array though).
no Oluseyi....if you look at his original post then you can see that he is only using x++ and not x+=4


"I pity the fool, thug, or soul who tries to take over the world, then goes home crying to his momma."
- Mr. T
well for some reason the program wouldnt run properly with
a main like this

void main()

but this made it work

int main(int argc, char *argv[])

This topic is closed to new replies.

Advertisement