-
January 14th, 2014, 09:20 PM
#1
printing arrays to file. in order
hey guys i have 3 arrays (even, odd and negative), they are all different sizes, but they maximum elements they can have is 50. how do i write them to a file in this format
EVEN ODD NEGATIVE
2 3 -2
4 5 -4
6 7 -9
Code:
size = 50; //they dont all 50, its just that array cant be bigger than 50
for (int i =0; i < size; i++)
{
cout <<setw(5);
if (even[i] != 0)
{
myfile << eList[i];
myfile << endl;
}
else
myfile << " ";
}
for (int i =0; i < size; i++)
{
cout <<setw(5);
if (odds[i] != 0)
{
myfile << oList[i];
myfile << endl;
}
else
myfile << " ";
}
for (int i =0; i < size; i++)
{
myfile <<setw(5);
if (negatives[i] != 0)
{
myfile << nList[i];
myfile << endl;
}
else
myfile << " ";
}
i have no idea.. please help... i know the code above is wrong, but thats the best i got
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|