Early warning this is for school work. I'm not putting the actual assignment but what I'm having a similar problem in a basic version of my assignment.
class CL
{
private:
int a,b;
public:
int addition(int a,int b);
};
1 2 3 4
int CL::addition(int a,int b)
{
return a+b;
}
in the txt file I only have the numbers 5 and 9 with a space in between them. but when I get the output file it said The addition is -1717986920. Can anybody help?? Thanks i'm learning file io, but he wants us to use headers and functions
String buffer;
//main functions and stuff
getline(myiput, buffer);
/*extract the variables and seperate them with a for loop and an
If statement or such to skip the space in between the variables*/
I just compiled it in Visual Studio 2010 and your code works fine. I would maybe check to see if the .txt file is in the correct place and that it has the numbers in it. I know sometimes I make the file then move it to the correct folder, but end up editing the file that is outside the folder. It maybe worth checking out. What compiler are you using?
it's placed in the resource file of the Project. I'm using visual studio 2008. The weird thing though is when I compile it it's a blank screen. I read that I have to search the debug folder and run the exe in order to get the output .txt. Could that mean it's an error at some point there?
If you use explorer to get to your input file, you should see it in the same folder that your c++ and header files are. It should create the output file for you as well where your c++ and header files are. Find the output file that it created for you, that is where your input file should go. Although I am going to compile it in 2008 and see if the file is created for me. I will let you know if you don't solve it be the time I do it.
Just worked in visual c++ express, make sure that file is in the right place, delete it and start fresh. Create the file and save as, it should be saved to visual 2008/project/projectName/....keep clicking the folders that has your projectName until there is no more to click and save it there. Hope this helps.
Edit: It also created the new file for me in the same place.