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

my C++ code:


#include
#include
#include
using namespace std;

int main()
{
char a[128]="**** the truth!";
cout<
ofstream outfile("temp.txt",ios::out);
for(int i=0;i<=127;i++)
{if(a[i]!=NULL)outfile< outfile.close();

char b[128];
ifstream infile("temp.txt",ios::in);
for(int j=0;j<=127;j++)
{infile>>b[i];}
cout< infile.close();

return 0;
}



result:
**** the truth!
烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫!烫烫烫烫
烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫烫蘁

2007-03-20 02:19:28 · 1 answers · asked by gardenants 1 in Computers & Internet Programming & Design

1 answers

Probably because of this code

for(int j=0;j<=127;j++)
{infile>>b[i];}

Your for loop increments j but in the loop you are using b[i].
i should have a value of 127 or rubbish if it is out of scope.

2007-03-20 02:52:14 · answer #1 · answered by AnalProgrammer 7 · 0 0

fedest.com, questions and answers