blank output need help asap

this is my code i try to run it it just give me blank screen no out put when i debug i get this statement




computerprogrammin13.exe': Loaded 'C:\Users\neha\Documents\Visual Studio 2010\Projects\computerprogrammin13\Debug\computerprogrammin13.exe', Symbols loaded.
'computerprogrammin13.exe': Loaded 'C:\Windows\SysWOW64\ntdll.dll', Cannot find or open the PDB file
'computerprogrammin13.exe': Loaded 'C:\Windows\SysWOW64\kernel32.dll', Cannot find or open the PDB file
'computerprogrammin13.exe': Loaded 'C:\Windows\SysWOW64\KernelBase.dll', Cannot find or open the PDB file
'computerprogrammin13.exe': Loaded 'C:\Windows\SysWOW64\msvcp100d.dll', Symbols loaded.
'computerprogrammin13.exe': Loaded 'C:\Windows\SysWOW64\msvcr100d.dll', Symbols loaded.
The program '[3692] computerprogrammin13.exe: Native' has exited with code 0 (0x0).


did i miss anything in my code or some thing wrong with me that i cant figure it out



#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
string firstname, middlename , lastname;
string line;
ifstream infile;
ofstream outfile;
infile.open("computerprogrammin13.txt");
outfile.open("computerprogrammin13.txt");

while(getline(infile,line))
{
int comma = line.find(',');
int length = line.length();


lastname = line.substr(0,comma);

int space_after_firstname = line.find(' ',comma+2);
cout<<line<<endl;

if(space_after_firstname != -1)
{
firstname = line.substr(comma+2,
space_after_firstname-comma-2);

middlename =line.substr
(space_after_firstname+1,length);
outfile<<firstname<<"jason"<<middlename<<"brain";
outfile<<firstname<<"lisa"<<middlename<<"maria";
outfile<<firstname<<"anil"<<middlename<<"kumar";
outfile<<firstname<<"sumit"<<middlename<<"sahil";
outfile<<firstname<<"rhonda"<<middlename<<"beth";
}
else
{
firstname = line.substr(comma+2,length);
outfile<<firstname<<"jason";
outfile<<firstname<<"lisa";
outfile<<firstname<<"anil";
outfile<<firstname<<"sumit";
outfile<<firstname<<"rhonda";
}
outfile<<lastname<<"miller"<<endl;
outfile<<lastname<<"blair"<<endl;
outfile<<lastname<<"gupta"<<endl;
outfile<<lastname<<"arora"<<endl;
outfile<<lastname<<"saleh"<<endl;

}


return 0;
}
Please put your code in side of a code-block so we can actually read it :)
All of your output seems to be going to a file.

Except for
cout<<line<<endl;, that is.

I might be wrong, but I think if you do something like
1
2
3
4
ifstream infile;
ofstream outfile;
infile.open("computerprogrammin13.txt");
outfile.open("computerprogrammin13.txt");

where you open the same file like that, outfile will clear out everything that's in the file.

Just tested with this:
1
2
3
4
5
6
7
#include <fstream>

int main()
{
	std::ifstream blah("blah.txt");
	std::ofstream blahy("blah.txt");
}


Before, I had a file named "blah.txt" containing a bunch of random junk.
After I ran this, blah.txt was empty, which seems to suggest that blahy discarded everything in the file.
(not sure if the results would be different with a different computer/compiler, though)

If that's the case, that would mean that your file, in effect, gets trashed when you open it like that, so your cout statement would end up printing a blank string.
I would suggest making your input file different from your output file. (that's the easiest way to do it)
ok so i change it and here its i change statement to cout too but still getting the same blank screen


#include<iostream>
#include<string>
#include<fstream>
using namespace std;
int main()
{
string firstname, middlename , lastname;
string line;
ifstream infile;
ofstream outfile;
std::ifstream computerprogrammin("computerprogrammin.txt");
std::ofstream computerprogrammin13("computerprogrammin13.txt");

while(getline(infile,line))
{
int comma = line.find(',');
int length = line.length();


lastname = line.substr(0,comma);

int space_after_firstname = line.find(' ',comma+2);
cout<<line<<endl;

if(space_after_firstname != -1)
{
firstname = line.substr(comma+2,
space_after_firstname-comma-2);

middlename =line.substr
(space_after_firstname+1,length);
cout<<firstname<<"jason"<<middlename<<"brain";
cout<<firstname<<"lisa"<<middlename<<"maria";
cout<<firstname<<"anil"<<middlename<<"kumar";
cout<<firstname<<"sumit"<<middlename<<"sahil";
cout<<firstname<<"rhonda"<<middlename<<"beth";
}
else
{
firstname = line.substr(comma+2,length);
cout<<firstname<<"jason";
cout<<firstname<<"lisa";
cout<<firstname<<"anil";
cout<<firstname<<"sumit";
cout<<firstname<<"rhonda";
}
cout<<lastname<<"miller"<<endl;
cout<<lastname<<"blair"<<endl;
cout<<lastname<<"gupta"<<endl;
cout<<lastname<<"arora"<<endl;
cout<<lastname<<"saleh"<<endl;

}


return 0;
}
Well, does "computerprogrammin.txt" exist in the same directory as the .exe file, and does it contain a valid input for the program?
ummm computerprogrammin exist in my visual studio 2010 /project floder most of my projects starts with computerprogrammin...... but this one is the hard one i send 3 days just to fix it but no luck at all and its due in few hours
Topic archived. No new replies allowed.