Violet_82 89 Posting Whiz in Training

Hi, yeah, you're quite right about readibility, I didn't know I could break each line like that, I thought it would have caused an error or something.

About this

When the value of the variable letter is 65, the alphabet A is displayed. When the value is 90 the variable Z is displayed. At this time the value of counter is 26. The for the values 91-96 there is no display. Then the value of letter becomes 97. Counter gets incremented to 27, we go to the next line and the letter a is displayed

I think I am following but I thought that if I say

if (counter==26)//counter condition
cout<<" \n";

the line space will be placed after the 26th character but instead it places it after character 25.

I can show you another quick example though, because I don't seem to be getting this counter business and line breaks at all.
This example is in the book I am using for C++(C++ a beginner's guide - Herbert Schildt). it goes:

#include<iostream>
using namespace std;
int main()
{
double f;
double m;
int counter;

counter=0;

for(f=1.0;f<=100.0;f++)
{
m=f/3.28;
cout<<f<<" feet is"<<m<<"meters.\n";
counter++;
if (counter==10)
{
cout<< "\n";
counter=0;
}
}

	return 0;
}

As you can see it's

if (counter==10)
{
cout<< "\n";

so here the line breaks is actually placed after 10 lines as it says in the program, whereas in my program if I say

if (counter==26)//counter condition
cout<<" \n";
Violet_82 89 Posting Whiz in Training

Hi there,
quick (and I am sure) simple question on a program I have just created.
here's the code:

#include<iostream>
using namespace std;

int main()
{
char letter;
int counter=0;//set the counter to 0
for (letter=65; letter<=122; letter++)
{if ((((((letter==91)||(letter==92)||(letter==93)||(letter==94)
	 ||(letter==95)||(letter==96))))))continue;
counter++;//increment the counter in the loop
		if (counter==27)//counter condition
		cout<<" \n";
cout<<letter<<" ";

}
counter=0;//reset the counter
return 0;
}

what's bugging me is the counter. I included

int counter=0;

because I wante to have a space between the upper case alphabet and the lower case one, but I had to make it equal to 27 to get the space right and the letters of the alphabet are 26...why is that?
thanks

Violet_82 89 Posting Whiz in Training

thanks guys :)

Violet_82 89 Posting Whiz in Training

Thank you VernonDozier, I can ensure you that I always try hard myself before asking anything on the forum, the reason being that I want to learn how to program.
Thanks for posting the code, I had a look at it and I don't think I could have done on my own though, because there are still lots of things I don't know, like your directives

#include <ctime>
#include <cmath>

(never seen them before) and like boolean variables just to name some of them.

Thanks also for the clarification on the array, it's better now :)

Violet_82 89 Posting Whiz in Training

Thanks guys.
I have tried it in a slightly different way (using some of the code that I posted at the beginning, just to test it and then I will try with VernonDozier's code.)
But one thing at a time.

Now, here's what I came up with but I would like, if there is anybody patient enough, to go through it almost line by line:

#include <iostream>
using namespace std;
const int MAX = 10; //I use a constant to define the dimension of the array

int main()
{
	int i; //this will be one of the indexes of my array
	int j; //this will be then the second index of my array
	int Data[MAX] = {6,34,87,12,43,11,65,99,50,10};
	for (i=0;i<MAX;i++) /*This is just the loop used to print all the values of my array isn't it?*/
		{
		cout <<Data[i]<<" - ";
		}
	for (i=0; i<MAX; i++)/*sort starts. What's the purpose of this loop? I tried to remove it from the code and the program doesn't work but I don't quite understand what it does */
	for (j=MAX-1;j>=i;--j)/*Why do we need a second loop with a second index and why is it --j and not j--?*/
		if (Data[j-1]>Data[j]) //These lines
			{ //are 
			int temp = Data[j-1]; //all
			Data[j-1] = Data[j]; //clear, it is
			Data[j] = temp; //probably the only thing I really
			} //understood in this program!
	for (i=0;i<MAX;i++) /*This loop is just for printing the values 
of the array after the swap has happened*/
		cout <<" "<<Data[i]; …
Violet_82 89 Posting Whiz in Training

SO does it look like something like:

#include <iostream>
using namespace std;
const int MAX = 5;
void main ()
{
int i;
int Data[MAX] = {51,62,31,27,90};
for (i=0; i<MAX; i++)
bool swapped = false;
for (int j=0;j<i+1; ++j)
{
	if a[j]<a[j-1
	{
		a[j]=a[j-1];
	}
	swapped=true;

if (swapped=false) 
break;
}

}
Violet_82 89 Posting Whiz in Training

That doesn't look right. The code should be in this format:

#include <iostream>
#include <conio.h>

using namespace std;
int main ()
{
cout << "**********" << endl;
cout << "* *" << endl;
cout << "* *" << endl;
cout << "**********" << endl;
return 0;
}

cout is not a variable so you can't say

int cout

.

Violet_82 89 Posting Whiz in Training

that's fine, I understand the process, but what I don't understand is how to translate that into code and what functions the loops have in the process of ordering the numbers.

Violet_82 89 Posting Whiz in Training

I think that what confuses me are the loops actually. Now, I had a look at the pseudocode on that website, but why do we need to use 2 variables n and j and not only one instead?
My understanding is that the pseudocode is telling me this:
do a for loop so that

for (n=0; i<MAX; ++i)
bool swap =false;
for (int j=0; j<i+1; ++j)
{
if a[j]<a[j-1]
{
a[j]=a[j-1];
}
}
swapped = true;
if (swapped=false) 
break;

But i think I don't understand the fuction of the loops...

Violet_82 89 Posting Whiz in Training

Hi there,
I am trying to get my head around the bubble sort but I don't seem to get it.
Now I have a program written by somebody which performs a bubble sort and I am trying to understand it but no much success. Here is the code:

#include <iostream> //This is my teacher's and it works fine.
 #include <math.h>
 using namespace std;
 
 const int MAX = 10;
 void main()
 {
 	int i;
 	int Data[MAX]; //1D array to hold data
 	for (i=0; i<MAX; i++)
 	{
 		Data[i]=rand() % 101;
 		cout <<" " << Data[i] << "\n";
 	}
 
 
 //sort the data array using the bubble sort
 for (i=0; i < MAX; i++)
 for (i=1; i < MAX; ++i)
 	for (int j = MAX - 1; j >=i; --j)
 		if (Data[j-1] > Data[j])
 		{
 			int tmp = Data[j-1];
 			Data[j-1] = Data[j];
 			Data[j] = tmp;
 		}
 		for (i=0; i < MAX; i++)
 			cout << Data[i] << "--";
}

I am trying to replicate this on my program which I 've just started:

#include <iostream>
using namespace std;
const int MAX = 5;
int main ()
{
int Data[MAX] = {51,62,31,27,90};
...

but obviously I don't want to copy it, I want to understand it first and then apply it to mine.
I also had a look at wikipedia http://en.wikipedia.org/wiki/Bubble_sort where there is some pseudocode, which helped me a little bit but there are things like flag variables that I haven't covered as yet, so I am not …

Violet_82 89 Posting Whiz in Training

Ok so I can simply remove the line that goes

#
if (f==5)

and nothing at all will change.
Let me get to this though:

But if you want to check for a certain value before entering the while loop, then you'd put the if statement first.

Any chance you can give me a practical simple example?Just so I understand it properly
thanks

Violet_82 89 Posting Whiz in Training

ok, so fondamentally, what you guys are saying is that the if statement has to be after the loop, whic makes sense, because we need to tell exit the loop if f=5.
I presume this thing of having the f statement after the loop is always valid when they are used together

Violet_82 89 Posting Whiz in Training

Hi there,
thanks for that. uhm, I thought the next line was the "well done" bit because I have the loop and then the if statement so, if f is not 5 the loop will execute, if f is 5 then the loop won't execute and it will jump straight to the "well done" line. Is it not like that?
thanks

Violet_82 89 Posting Whiz in Training

Hi guys, I have just written 2 versions of this simple program:

#include <iostream>
using std::cin;
using std::cout;

int main ()
{
cout << "This program counts from 10 to 0. \nGuess the missing number.\n";
int n;
int f;
for (n=10; n>0; n--)
	{
	if (n==5) continue;
	cout << n << ", ";
	}
cout << "So, type the missing number here: ";
cin >>f;
	if (f==5)
	cout << "Well done!\a\a\a";
	while (f!=5)
	{
	cout << "Wrong answer, try again!\nEnter the number here: ";
	cin >> f;
	}
	
return 0;
}

I compiled it and executed it but it doesn' work properly: if I guess the number on the first attempt, all good, but, say that at the first attempt I try with 4 (and the program will obviously say tht that's wrong asking me to try again) and then I type 5, the program terminates, without showing me "Well done" and ringing the system alarm three times.
Now in the second version I changed the order of the if statement and the while loop so that line 17 and 18 come after the while loop:

#include <iostream>
using std::cin;
using std::cout;

int main ()
{
cout << "This program counts from 10 to 0. \nGuess the missing number.\n";
int n;
int f;
for (n=10; n>0; n--)
	{
	if (n==5) continue;
	cout << n << ", ";
	}
cout << "So, type the missing number here: ";
cin >>f;
	
	while (f!=5)
	{
	cout << "Wrong answer, try …
Violet_82 89 Posting Whiz in Training

Problem solved, thanks guys, I wasn't using it correctly. I am used to Visual C++ 6.00, which works in a slight different way for some reasons
thanks
again

Violet_82 89 Posting Whiz in Training

Hi there, could anybody tell me how to compile a program and run it using Visual C++ 2005?
This is what I have done:
-File, New, Project;
-In the menu, I choose Win 32 and then Win 32Console application; then I give a name to the project and save that on my desktop;
-on the win 32application wizard I click on next and then choose Empty project, then finish.
-the new project is now running so I choose File, New, File and then choose C++File in the menu, then ok
-then I paste my code in, F7 to compile it and get this:
========== Build: 0 succeeded, 0 failed, 1 up-to-date, 0 skipped ==========
then F5 to run it but I have an error message telling me that "it is unable to start the program...The system cannot find the file specified"...
Any suggestion at all?
Thanks

Violet_82 89 Posting Whiz in Training

thanks guys, I will bear in mind not to use the goto.

Violet_82 89 Posting Whiz in Training

hi nats01282,
thanks for posting that, it is actually really helpful because it shows exaclty how to initialize the variables. I tried myself with my program (to initialize the variables few days ago), and I can see why I failed, because the structure of my program was completely wrong, it didn't make any sense.

Looking at your program, there are few things I haven't touched yet, like the goto statements but I get the general idea, so thanks. SO far I got to the while loop, but I will do some more today.

Violet_82 89 Posting Whiz in Training

I see, yes I haven't realized that I had superfluos conditions, I should be thinking a bit more.
Thanks for your help

Violet_82 89 Posting Whiz in Training

I added 12 to the result so that I have

int result = 12;

but it didn't help, because I seem to understand that all my variables need to be initialized taking into consideration the compiler warnings. I didn't know that variables in general had to be initialised, I thought that was optional. The thing is I am not sure what values my variables should get (apart from the result of course) but nevermind, I will go on with the theory a bit more and have a look at the "if conditions" with the "ELSE statement" as suggested by WaltP.
thanks

Violet_82 89 Posting Whiz in Training

Hi there, thanks for that. Well, the reasons why I haven't used ELSE statement because I haven't heard of them untill now, I haven't got that far yet. I compiled my program again, and I got few warnings:
--------------------Configuration: 10 - Win32 Debug--------------------
Compiling...
10th.cpp
Z:\example\10\10th.cpp(53) : warning C4700: local variable 'myInstructions' used without having been initialized
Z:\example\10\10th.cpp(19) : warning C4700: local variable 'Addition' used without having been initialized
Z:\example\10\10th.cpp(31) : warning C4700: local variable 'Subtraction' used without having been initialized
Linking...

10.exe - 0 error(s), 3 warning(s)

I thought to myself, well thery are just warnings so nothing to worry about, but now thinking about that again, maybe I should take them more seriously. I guess I should focus a bit more on the theory then...

Violet_82 89 Posting Whiz in Training

Uhm, maybe the problem is with the variables I used...maybe I got things wrong with this program. All I wanted do do was for a user to be able to make a choice between addition and subtraction, and the program to be able to present him with respectively "Enter the right number: 9+3= " or "Enter the right number: 9-3= " depending on user's choice...did I choose the wrong code then? Sorry I am not quite sure....

Violet_82 89 Posting Whiz in Training

Ok, I used the cin.ignore ( 80, '\n' ); in the code,but also I think I noticed something wrong in main and now I moved cin one line down so that the source code is now:

//seventh
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

class Maths
{
public:
void enterInstructions( int instructions )
	{
	cout <<"I want to do a: \nAddition\nSubtraction\nType your choice here: "<< instructions << endl;
	}
void conditions(int instructions)
	{
	int result;
	int Addition;
	int Subtraction;
	if ( instructions == Addition )
	cout << "Enter the right number: 9+3= " << endl;
	cin >> result;
	if ( result == 12 )
	cout << "Well done, you're a star!" << endl;
	if ( result != 12 )
	cout << "Sorry, wrong answer!" << endl;
	if ( result < 12 )
	cout << "Sorry, wrong answer!" << endl;
	if ( result > 12 )
	cout << "Sorry, wrong answer!" << endl;

	if ( instructions == Subtraction )
	cout << "Enter the right number: 9-3= " << endl;
	cin.ignore ( 80, '\n' ); 
	cin >> result;
	if ( result == 6 )
	cout << "Well done, you're a star!" << endl;
	if ( result != 6 )
	cout << "Sorry, wrong answer!" << endl;
	if ( result < 6 )
	cout << "Sorry, wrong answer!" << endl;
	if ( result > 6 )
	cout << "Sorry, wrong answer!" << endl;
	}
};

int main()
{
int myInstructions;
Maths operations;
cout << "What do you want to do?\n";

operations.enterInstructions( …
Violet_82 89 Posting Whiz in Training

Hi guys,
I am having problems with a simple program I wrote, here's the source code:

//seventh
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

class Maths
{
public:
void enterInstructions( int instructions )
	{
	cout <<"I want to do a: \nAddition\nSubtraction\nType your choice here: "<< instructions << endl;
	}
void conditions(int instructions)
	{
	int result;
	int Addition;
	int Subtraction;
	if ( instructions == Addition )
	cout << "Enter the right number: 9+3= ";
	cin >> result;
	if ( result == 12 )
	cout << "Well done, you're a star!";
	if ( result != 12 )
	cout << "Sorry, wrong answer!";
	if ( result < 12 )
	cout << "Sorry, wrong answer!";
	if ( result > 12 )
	cout << "Sorry, wrong answer!";

	if ( instructions == Subtraction )
	cout << "Enter the right number: 9-3= ";
	cin >> result;
	if ( result == 6 )
	cout << "Well done, you're a star!";
	if ( result != 6 )
	cout << "Sorry, wrong answer!";
	if ( result < 6 )
	cout << "Sorry, wrong answer!";
	if ( result > 6 )
	cout << "Sorry, wrong answer!";
	}
};

int main()
{
int myInstructions;
Maths operations;
cout << "What do you want to do?\n";
cin >> myInstructions;
operations.enterInstructions( myInstructions );
operations.conditions( myInstructions );


return 0;
}

The program doesn't execute properly. When I launch the first thing that I see on the screen is the "What do you want to do?" message and then I have to input a …

Violet_82 89 Posting Whiz in Training

Great, thanks!

Violet_82 89 Posting Whiz in Training

right, the cin.ignore ( 80, '\n' ); line worked a treat!!
So basically by using that line I effectively flushed the input stream, and that was the problem, wasn't it?
Thanks

Violet_82 89 Posting Whiz in Training

Ok sorry, maybe with all the changes it got a bit confusing, my fault.
Let me recap.
the original (I will put just the main() because the rest is the same as before) is this

int main()

{

int s;
int x;
int y;
int z;

cout << "The first number is: \n";
cin >> x;
cout << "The second number is: \n";
cin >> y;
cout << "The third number is: \n";
cin >> z;

s = additions (x,y,z);

cout << "The result is: " << s << "\n";

if (s == 4)

cout << " \a\a\a";

return 0;

}

Then I followed Agni's suggestion and I added cin.ignore() after the last cin and cin.get() and also endl; (my own initiative) and corrected the stray /nso that the code looked like:

int main()

{
	int s;
	int x;
	int y;
	int z;
	cout << "The first number is: \n";
	cin >> x;
	cout << "The second number is: \n";
	cin >> y;
	cout << "The third number is: \n";
	cin >> z;
	cin.ignore();

	s = additions (x,y,z);
	
	cout << "The result is: \n" << s << endl;

	if (s == 4)
	cout << " \a\a\a";
	cin.get();
	return 0;
}

Basically, no difference the problem persists but, I tried - as suggested - to run the program from the terminal, so open the terminal navigate to the directory where the program is and run it from there rather than click on the exe file in the …

Violet_82 89 Posting Whiz in Training

Sort of: if the result of the operation is 4the terminal window display the result "the result is: 4". any other resut the terminal doesn't display the result but, when I put the last integer and click enter to display the result the terminal shuts without returning anything. It would be easier if you try the program yourself I guess, but I don't want to trouble you that much!

Violet_82 89 Posting Whiz in Training

Oh, I see sorry!
Done, but still same problem. Does it have anything to do with maybe the position of the lines in main()? Sorry just doing silly guesses.
Is it that frequent to have a program that compiles ok but doesn't execute properly? sorry, but it is really annoying when it does that:confused:

Violet_82 89 Posting Whiz in Training

Hi there, I tried to the cin.ignore; line (I had to add the semicolon because the compiler didn't like it without) but nothing changes except for a warning during compilation which says:
--------------------Configuration: second - Win32 Debug--------------------
Compiling...
second.cpp
Z:\example\sec\second.cpp(28) : warning C4551: function call missing argument list
Linking...

second.exe - 0 error(s), 1 warning(s)

So the program now looks like the below
Again it works only when the result is 4, any other result the program doesn't finish its execution in the terminal.
I read the tutorial, but in some places it is a bit too advanced for me to be honest. SO basically in my program there is some character kicking around and i need to flush the stream...Might be a bit naive but how about about std::endl;? doesn't it help? I also added that but to no avail...

#include <iostream>

using std::cout;
using std::cin;
using std::endl;

int additions (int a, int b, int c)

{
int k;
k = a+b-c;
return k;
}

int main()

{
int s;
int x;
int y;
int z;
cout << "The first number is: \n";
cin >> x;
cout << "The second number is: \n";
cin >> y;
cout << "The third number is: \n";
cin >> z;
cin.ignore;

s = additions (x,y,z);

cout << "The result is: " << s << endl; "\n";

if (s == 4)
cout << " \a\a\a";
cin.get();
return 0;
}
Violet_82 89 Posting Whiz in Training

thanks. It seems to work only if the result is 4. If it is another number the program doesn't execute...I think this happened also before adding the line. Is there anything wrong in the code?

Violet_82 89 Posting Whiz in Training

Hi there,
I am experiencing a problem during the program execution.
Here is the program:

#include <iostream>

using std::cout;
using std::cin;

int additions (int a, int b, int c)

{
	int k;
	k = a+b-c;
	return k;
}

int main()

{
	int s;
	int x;
	int y;
	int z;
	cout << "The first number is: \n";
	cin >> x;
	cout << "The second number is: \n";
	cin >> y;
	cout << "The third number is: \n";
	cin >> z;

	s = additions (x,y,z);
	
	cout << "The result is: " << s << "\n";

	if (s == 4)
	cout << " \a\a\a";
	return 0;
}

Basically, when I click on the exe file in the debug folder, the program doesn't execute properly: it asks for the first number, second and third and then when I click enter the terminal disappears (I am using windows XP and the compiler is VC++ 6.0 trial copy).

If I instead compile the program and run it from VC++ (with ctrl F5) everything goes well...what am I doing wrong?
Thanks

Violet_82 89 Posting Whiz in Training

Wicked, thanks a lot, now I think it is clearer.
And now, tutorial time!!
Cheers

Violet_82 89 Posting Whiz in Training

Great thanks for that, it is much clearer now, and I will definitely read the tutorials, I am sure they will help.
One more thing: you described line 14 in main() really clearly, what happens instead with line 8 in main()? What's the effect of that call?
Thanks

Violet_82 89 Posting Whiz in Training

Thanks for that guys. I will certainly read the tutorials, maybe they will clarify the issue. I think I used the wrong choice of words when I said that the code changes. You're quite right, I think I get confused with how the variables change.
Is there any chance you guys could quickly explain how the variables change in that little program I got from my book (Deitel and Deitel C++ how to program), because it is not really clear from the book, or do you think I should read the tutorials first?

Violet_82 89 Posting Whiz in Training

I see, but I think the problem is more general for me, as in I don't get how the the calls work. Let me get this straight:
Lines 53-55 call the function on lines 19-22 and in particular they assign the string variable "nameOfCourse" - declared in line 45 - to line 19 so that line 19 "becomes"

#
void setCourseName( string nameOfCourse)

, but then...I get lost. Since in line 21 - which I guess is an assignment statement -

courseName = name

line 19 becomes what?

Then let's jump to lines 49-50. You said that I need that line because the data member courseName is private: now, private values cannot be called outside the class they are declared in, so the function "main" cannot call that private value and uses the "get" function to call it, isn't it correct? But what happens when line 49 calls the "get" function (I mean in the code) apart from getting the name of the course to be displayed on the screen?

I think I am failing to understand the interrelashionships between functions which is why I might need a detailed explanation of what the the above mentioned functions do in this program...
Thanks a lot

Violet_82 89 Posting Whiz in Training

Hi there,
I am trying to get my head around this simple program, but there are things that really don't make sense...

here's the program:

// Fig. 3.5: fig03_05.cpp
// Define class GradeBook that contains a courseName data member
// and member functions to set and get its value; 
// Create and manipulate a GradeBook object.
#include <iostream>
using std::cout; 
using std::cin;
using std::endl;

#include <string> // program uses C++ standard string class
using std::string;
using std::getline;

// GradeBook class definition
class GradeBook
{
public:
   // function that sets the course name
   void setCourseName( string name )
   {      
      courseName = name; // store the course name in the object
   } // end function setCourseName
   
   // function that gets the course name
   string getCourseName() 
   {
      return courseName; // return the object's courseName
   } // end function getCourseName

   // function that displays a welcome message
   void displayMessage()
   {
      // this statement calls getCourseName to get the 
      // name of the course this GradeBook represents
      cout << "Welcome to the grade book for\n" << getCourseName() << "!" 
         << endl;
   } // end function displayMessage
private:
   string courseName; // course name for this GradeBook
}; // end class GradeBook  

// function main begins program execution
int main()
{
   string nameOfCourse; // string of characters to store the course name
   GradeBook myGradeBook; // create a GradeBook object named myGradeBook
   
   // display initial value of courseName
   cout << "Initial course name is: " << myGradeBook.getCourseName() 
      << endl;

   // prompt for, input and set …
Violet_82 89 Posting Whiz in Training

Brilliant, thanks for your help!

Violet_82 89 Posting Whiz in Training

Ah ok, so let's say that I email the exe file to myself and open it on another machine which has no VC++ on it: the program will run as filename.exe without pause command, isn't it right?

Violet_82 89 Posting Whiz in Training

oh yeah, thanks :$...sorry!
But if I run the program from VC++ in the terminal window I've got a message saying "press any key to continue", whereas if I run it from the exe file in the debugger folder that doesn't happen...how's that?

Violet_82 89 Posting Whiz in Training

Hello there,
can anybody help me with this? I have a simple program like the attached. What I would like to do is to come up with an executable file that I can email to myself and execute on another machine. What happens at the moment is this: I wrote the program, compiled it and run it with Visual C++ and as a result I've got a folder with about 6 files and another subfolder called debug. Now, is there a way to come up with a single exe file instead or am I saying something completely silly? Sorry but I have just started with C++...
If possible how difficult is it?
thanks

Violet_82 89 Posting Whiz in Training

thanks everybody guys, for now I followed Athlon32's suggestion and, even if I can't see the Empty Project and Precompiled Headers radio button I managed to compile and execute the program. I will need to do some readings about Visual C++ as soon as I can, but I was mainly interested in getting my program run. I will probably post again here, because I am still at the beginning!!
Thanks again

Violet_82 89 Posting Whiz in Training

Hi there,
basically the issue was that I couldn't work out how to use Visual C++ (I have got version 6.0). I managed to find some short tutorial, but still can't get my head around that. I was trying to compile a simple program (which I uploaded as an attachment) I found on my manual, but I am not sure how to do it.
I have selected File, New, Win32 Application, gave the project a name (Example 1), then selected "a typical Hello World! application", finish and Ok. Then with the new project open, I go File, New, and choose C++ source file, give it file name "Example final", select a location and ok. The, when I paste the code attached, I click F7 to compile and I got the following error:
--------------------Configuration: Example 1 - Win32 Debug--------------------
Compiling resources...
Compiling...
StdAfx.cpp
Compiling...
Example 1.cpp
Example final.cpp
c:\documents and settings\antobbo_2\desktop\example\example 1\example final.cpp(28) : fatal error C1010: unexpected end of file while looking for precompiled header directive
Generating Code...
Error executing cl.exe.

Example 1.exe - 1 error(s), 0 warning(s)

Sorry, I am sure it will be a really silly mistake!
Thanks

Violet_82 89 Posting Whiz in Training

Hi there, I am new to C++ and trying to get my head around it. I am writing really simple and small programs and I have Visual C++. Now, can anybody summarize how I can run a program I wrote with C++ on Visual? The guide that comes with the product doesn't seem to be that helpful, so I was just wondering if you guys can help me/telling me where to find a simple guide on how to run my own programs.
Thanks