Log in

View Full Version : [PROGRAMMING] C++ Program



David_3033
10-07-2012, 21:33
Completely new and suck so far at C++. I am having trouble in my class and the teacher sucks. So mostly and am stuck learning it all myself via book / video tutorials.

I have been having some trouble getting this homework assignment done perfectly. It runs and works, but I still can't figure out how to get a loop where it will allow for multiple numbers to be inputs by the user before it ends. So it only runs once then quits. It works where you can input "c a l l H o M E" and it will output 225-5466. Which is what it's suppose to do. But the loop I need help on and I don't know which one to use or how...

actual problem:
To make telephone numbers easier to remember, some companies use letters to show their telephone numbers. For example, using letters, the telephone number 438-5626 can be shown as GET LOAN. In some cases, to make a telephone number meaningful, companies might use more than seven letters. For example, 256-5466 can be displayed as CALL HOME, which uses eight letters. Write a program that prompts the user to enter a telephone number expressed in letters and outputs the corresponding telephone number in digits. If the user enters more than seven letters, then process only the first seven letters. Also output the - (hypen) after the third digit. Allow the user to use both uppercase and lowercase letters as well as spaces between words. Moreover, your program should process as many telephone numbers as the user wants.


Here is what I have so far with Visual Studio 2010 express:



#include
<iostream>

#include
<string>


using namespace std;


char letter, redo;

int counter = 0;


int main(){


cout << "Enter the letters you would like to convert to a phone number." << endl;


while(counter < 8){



cin.get(letter);


if(counter==0){

cout<<"\nThe corresponding number is: " << endl;;

}

if(counter==3){

cout << '-';

counter++;
}

switch(letter)

{


case'0':

cout << 0;

counter++;

break;

case'1':

cout << 1;

counter++;

break;

case'a': case'A': case'b': case'B': case'c': case'C': case'2':

cout << 2;

counter++;

break;

case'd': case'D': case'e': case'E': case'f': case'F': case'3':

cout << 3;

counter++;

break;

case'g': case'G': case'h': case'H': case'i': case'I': case'4':

cout << 4;

counter++;

break;

case'j': case'J': case'k': case'K': case'l': case'L': case'5':

cout << 5;

counter++;


break;

case'm': case'M': case'n': case'N': case'o': case'O': case'6':

cout << 6;

counter++;

break;

case'p': case'P': case'q': case'Q': case'r': case'R': case's': case'S': case'7':

cout << 7;

counter++;

break;

case't': case'T': case'u': case'U': case'v': case'V': case'8':

cout << 8;

counter++;

break;


case'w': case'W': case'x': case'X': case'y': case'Y': case'z': case'Z': case'9':

cout << 9;

counter++;

break;

case' ':

break;

default: cout << "Invalid input." << endl;

}

}


cout << endl << endl;

system("pause");

return 0;

}

David_3033
10-07-2012, 21:44
Oh also if too few numbers are input it gives those numbers back then outputs the Invalid input. Is this what I should be getting out of it?

Example:

Input:
aeio

Output:
The corresonding number is:
234-6Invalid input.

iamthesgt
10-07-2012, 23:16
As far as the loop goes, the simplest way is to create a variable to control the loop, and allow the loop to run while that variable is true.

I haven't tested this code, but it should work without much tweaking.



bool loop_ctrl=true;
do {
//all your code, starting with "cout << "Enter the letters you would like to convert to a phone number." << endl;", down to "cout << endl << endl;" should go here

string resp="";
cout << "Do you want to enter another number? [Yy]es [Nn]o";
cin>>resp;
if(resp[0] == 'Y' || resp[0] == 'y') {
loop_ctrl = true;
}
else // if(resp[0] == 'N' || resp[0] == 'n')
{
loop_ctrl = false;
cout << "Goodbye";
}

}
while(loop_ctrl);


As far as not being able to work it when there are less than 7 digits there, I would change the code to this:



bool format_correct=false;
while(!format_correct){
cout << "Enter the letters you would like to convert to a phone number." << endl;
string phone_word = "";
cin >> phone_word;
if (phone_word.length() < 8) //or however long the string needs to be for a 7-digit number, if you need other conditions
{
cout << "Insufficient string length. Please re-enter a string of at least 7 characters";
format_correct = false;
}
else
{
format_correct = true;
}
}

while(counter < 8)
//etc etc (other code remains the same with the exception of: )

switch(phone_word[counter]) //maybe an off-by-one error here. You'll have to check it

Ragingclue
10-08-2012, 08:20
+1 to everything he said above.

The only thing I'd do differently though is to to have a condition for the user entering a char besides 'Y', 'y', 'N', or 'n'. If you got fat fingers like me, there's a chance you slip when you go to hit the 'y', but if you're only using an if 'Y' or 'y', else everythingelse, that would cause the user to exit. But that's just semantics. Looks like he's got you covered pretty well.

iamthesgt
10-08-2012, 09:47
The only thing I'd do differently though is to to have a condition for the user entering a char besides 'Y', 'y', 'N', or 'n'. If you got fat fingers like me, there's a chance you slip when you go to hit the 'y', but if you're only using an if 'Y' or 'y', else everythingelse, that would cause the user to exit. But that's just semantics. Looks like he's got you covered pretty well.

Good point. I meant to put something in there about sanitizing input, but it slipped my mind. Always assume the user will mess up!

David_3033
10-08-2012, 11:35
The whole idea of bool and the way they are used really confuses me. :confused:

David_3033
10-08-2012, 11:44
+1 to everything he said above.

The only thing I'd do differently though is to to have a condition for the user entering a char besides 'Y', 'y', 'N', or 'n'. If you got fat fingers like me, there's a chance you slip when you go to hit the 'y', but if you're only using an if 'Y' or 'y', else everythingelse, that would cause the user to exit. But that's just semantics. Looks like he's got you covered pretty well.


How do you do everythingelse?

EDIT: Nevermind your just saying while it is "Y" or "y" continue any other input would end. I am hopeless, lol.

Ragingclue
10-08-2012, 11:48
The whole idea of bool and the way they are used really confuses me. :confused:

They're essential for code that depends on a certain condition either being met or not met first. What part confuses you?

David_3033
10-08-2012, 12:05
Ok, I did this part of it, but when it runs now it just goes straight to printing this:


Do you want to enter another number?
Y or y for yes, Or anything else to quit. GoodbyePress any key to continue. . .


Then the program quits.



bool loop_ctrl=true;
do {
//all your code, starting with "cout << "Enter the letters you would like to convert to a phone number." << endl;", down to "cout << endl << endl;" should go here

string resp="";
cout << "Do you want to enter another number? [Yy]es [Nn]o";
cin>>resp;
if(resp[0] == 'Y' || resp[0] == 'y') {
loop_ctrl = true;
}
else // if(resp[0] == 'N' || resp[0] == 'n')
{
loop_ctrl = false;
cout << "Goodbye";
}

}
while(loop_ctrl);

Ragingclue
10-08-2012, 12:17
Ok, I did this part of it, but when it runs now it just goes straight to printing this:


Do you want to enter another number?
Y or y for yes, Or anything else to quit. GoodbyePress any key to continue. . .


Then the program quits.



bool loop_ctrl=true;
do {
//all your code, starting with "cout << "Enter the letters you would like to convert to a phone number." << endl;", down to "cout << endl << endl;" should go here

string resp="";
cout << "Do you want to enter another number? [Yy]es [Nn]o";
cin>>resp;
if(resp[0] == 'Y' || resp[0] == 'y') {
loop_ctrl = true;
}
else // if(resp[0] == 'N' || resp[0] == 'n')
{
loop_ctrl = false;
cout << "Goodbye";
}

}
while(loop_ctrl);



Did you paste your code in there where the comment says to put your code in (pasted into quote below)? I haven't looked at it for syntax or logical issues, but if you had not pasted the snippet in there, then you would get the result you describe.


bool loop_ctrl=true;
do {

cout << "Enter the letters you would like to convert to a phone number." << endl;


while(counter < 8){



cin.get(letter);


if(counter==0){

cout<<"\nThe corresponding number is: " << endl;;

}

if(counter==3){

cout << '-';

counter++;
}

switch(letter)

{


case'0':

cout << 0;

counter++;

break;

case'1':

cout << 1;

counter++;

break;

case'a': case'A': case'b': case'B': case'c': case'C': case'2':

cout << 2;

counter++;

break;

case'd': case'D': case'e': case'E': case'f': case'F': case'3':

cout << 3;

counter++;

break;

case'g': case'G': case'h': case'H': case'i': case'I': case'4':

cout << 4;

counter++;

break;

case'j': case'J': case'k': case'K': case'l': case'L': case'5':

cout << 5;

counter++;


break;

case'm': case'M': case'n': case'N': case'o': case'O': case'6':

cout << 6;

counter++;

break;

case'p': case'P': case'q': case'Q': case'r': case'R': case's': case'S': case'7':

cout << 7;

counter++;

break;

case't': case'T': case'u': case'U': case'v': case'V': case'8':

cout << 8;

counter++;

break;


case'w': case'W': case'x': case'X': case'y': case'Y': case'z': case'Z': case'9':

cout << 9;

counter++;

break;

case' ':

break;

default: cout << "Invalid input." << endl;

}

}


cout << endl << endl;

string resp="";
cout << "Do you want to enter another number? [Yy]es [Nn]o";
cin>>resp;
if(resp[0] == 'Y' || resp[0] == 'y') {
loop_ctrl = true;
}
else // if(resp[0] == 'N' || resp[0] == 'n')
{
loop_ctrl = false;
cout << "Goodbye";
}

}
while(loop_ctrl);

iamthesgt
10-08-2012, 15:06
Yeah, combine my snippets into your program. And the bool is used there as loop control variables, e.g. "Continue while such-and-such boolean variable holds a value of true"

Sent from my DROID RAZR using Tapatalk 2

David_3033
10-08-2012, 17:26
This is what I did and it still quits if I put Y or y.


#include
<iostream>

#include
<string>


using
namespace std;


char
letter, redo;

int
counter = 0;


 

int
main(){


bool
loop_ctrl=true;

do
{

cout <<
"Enter the letters you would like to convert to a phone number." << endl;





while(counter < 8){



cin.get(letter);




if(counter==0){

cout<<
"\nThe corresponding number is: " << endl;;

}


if(counter==3){

cout <<
'-';

counter++;

}




switch(letter)

{




case '0':

cout << 0;

counter++;


break;




case '1':

cout << 1;

counter++;


break;




case 'a': case 'A': case 'b': case 'B': case 'c': case 'C': case '2':

cout << 2;

counter++;


break;



case 'd': case 'D': case 'e': case 'E': case 'f': case 'F': case '3':

cout << 3;

counter++;


break;




case 'g': case 'G': case 'h': case 'H': case 'i': case 'I': case '4':

cout << 4;

counter++;


break;




case 'j': case 'J': case 'k': case 'K': case 'l': case 'L': case '5':

cout << 5;

counter++;


break;




case 'm': case 'M': case 'n': case 'N': case 'o': case 'O': case '6':

cout << 6;

counter++;


break;



case 'p': case 'P': case 'q': case 'Q': case 'r': case 'R': case 's': case 'S': case '7':

cout << 7;

counter++;


break;



case 't': case 'T': case 'u': case 'U': case 'v': case 'V': case '8':

cout << 8;

counter++;


break;



case 'w': case 'W': case 'x': case 'X': case 'y': case 'Y': case 'z': case 'Z': case '9':

cout << 9;

counter++;


break;



case ' ':


break;



default: cout << "Invalid input." << endl;

}

}



cout << endl << endl;


string resp=
"";


cout <<
"Do you want to enter another number? \nY or y for yes, Or anything else to quit. ";

cin >> resp;


if (resp[0] =='Y' || resp[0]== 'y'){

loop_ctrl=
true;

}




else{

loop_ctrl=
false;

cout <<
"Goodbye";

}

}

while
(loop_ctrl);


 

system(
"pause");




return 0;

}

Ragingclue
10-08-2012, 17:57
Put int counter into watch window.

Prob won't fix it, probably the cin.get(). I won't be in front of the computer until tomorrow though.

Sent from my SGH-I747 using Tapatalk 2

iamthesgt
10-08-2012, 19:21
It might be my code for resp[0]. Maybe you can't do it quite that way. Try testing to make sure resp[0] contains "y" when you type in "yes".

Sent from my DROID RAZR using Tapatalk 2

Ragingclue
10-08-2012, 20:37
Regardless, make sure you reset counter on 'y' or 'Y' as it controls a loop.

Sent from my SGH-I747 using Tapatalk 2

David_3033
10-08-2012, 22:30
Ok for the most part it works. There are a few things that I removed. I had to add a "dummy" string later in the program. It took the extra characters and put them to my input for the resp part. Not sure how or why.


#include
<iostream>

#include
<string>


using
namespace std;

charletter, redo;

int
counter = 0;

string resp;


int
main(){


bool
loop_ctrl=true;

do
{

cout <<
"Enter the letters you would like to convert to a phone number." << endl;

counter = 0;

while(counter < 8){

cin.get(letter);

if(counter==3){

cout <<
'-';

counter++;

}
switch(letter){

case '0':

cout << 0;

counter++;

break;

case '1':

cout << 1;

counter++;

break;

case 'a': case 'A': case 'b': case 'B': case 'c': case 'C': case '2':

cout << 2;

counter++;

break;

case 'd': case 'D': case 'e': case 'E': case 'f': case 'F': case '3':

cout << 3;

counter++;
break;

case 'g': case 'G': case 'h': case 'H': case 'i': case 'I': case '4':

cout << 4;

counter++;


break;

case 'j': case 'J': case 'k': case 'K': case 'l': case 'L': case '5':

cout << 5;

counter++;

break;

case 'm': case 'M': case 'n': case 'N': case 'o': case 'O': case '6':

cout << 6;

counter++;
break;

case 'p': case 'P': case 'q': case 'Q': case 'r': case 'R': case 's': case 'S': case '7':

cout << 7;

counter++;

break;

case 't': case 'T': case 'u': case 'U': case 'v': case 'V': case '8':

cout << 8;

counter++;
break;

case 'w': case 'W': case 'x': case 'X': case 'y': case 'Y': case 'z': case 'Z': case '9':

cout << 9;

counter++;


break;



case ' ':


break;

default: cout << " " << endl;

}
}

string dummy;

cin >> dummy;

cout << endl << endl;

cout <<
"Do you want to enter another number? \nY or y for yes, Or anything else to quit. ";

cin >> resp;

cout << endl << endl;

}
while(resp[0] =='Y' || resp[0] == 'y');

cout <<
"Goodbye\n";
system("pause");
return 0;

}

Ragingclue
10-09-2012, 09:15
I think you had inputs still in the input buffer. If you don't parse them all, you'll end up getting them the next time you ask for an input. I think the dummy string should work fine, or you could have:



while(cin.get()!='\n'){ //clears input buffer
cin.clear();
}


And I know you've changed the if y to something else (making it instead the loop control variable), but in your old setup, combined with the above:



if(resp[0] == 'Y' || resp[0] == 'y') {
loop_ctrl = true;
counter=0;
cin.get(); //clears the carriage return from the buffer so next time you cin, you don't grab it
}


Probably another way to go about things would have been like how iamthesgt recommended, to first ensure the input is valid and handle such issues at that point, as opposed to parsing half of the expected input and realizing there's nothing left (leaving you with the invalid input error).

But don't forget the cin.get when you ask a user for input where you don't parse the entire input buffer (most notably carriage return).

When I run your new code as-is, I typed in one string of letters, got the proper response, and then entered a second string. The second string showed the resultant phone number in the console output, but then was never followed by a "would you like to continue" prompt (see attachment)....

iamthesgt
10-09-2012, 09:30
Ok for the most part it works. There are a few things that I removed. I had to add a "dummy" string later in the program. It took the extra characters and put them to my input for the resp part. Not sure how or why.

I took a look at it, but I can't figure out why it's doing that. Two quick things, though:
- DON'T use global variables like that. The variables should be contained within the function (in this case, main()). The exceptions would be where you haven't got to yet, and you handle them differently.
- Format the program so it's easier to read. (if you're already doing this, and the forum is just throwing it off, don't worry about it). See here (K&R style): http://en.wikipedia.org/wiki/Indent_style#K.26R_style

Like clue suggested, use cin.clear() (but that didn't work for me, so I may have used it wrong).

David_3033
10-09-2012, 10:40
When you say global variables are you talking about in the declaration part of the program? Before the int main()?

iamthesgt
10-09-2012, 11:39
When you say global variables are you talking about in the declaration part of the program? Before the int main()?

Yes. Variables should be stored in the applicable function, or in an enum or class if needed by multiple functions (not applicable in your case).

Ragingclue
10-09-2012, 11:55
I dicked around with it a bit. Thought I was in the clear with what we had before but then I realized the code must be able to properly parse spaces or dashes entered by the user, so that tied my little brain in a bit of a knot.

This is what I got going right now. I tried what I could to throw it off a bit but it seems to do the job. If you have some questions as far as why certain things were done, let me know. It's ugly and it's not polished, and I can't promise I didn't have any d'oh moments in there, but seems to work as-is after a quick rework.



#include <iostream>
#include <string>

using namespace std;

int main(){
bool loop_ctrl=true;
int outcounter=0;
int incounter=0;
string phone_word;
char letter, redo;
do{
bool yornctrl=false;
bool format_correct=false;
int garbagechars=0;
cout << "Enter the letters you would like to convert to a phone number:" << endl;
while(!format_correct){
phone_word = "supercalafragilisticexpealidocious";
getline(cin, phone_word);
for(int i=0; i<phone_word.length(); i++){ //let's find out how long our actual string is (letters and numbers only)
if (phone_word[i]==' ' || phone_word[i]=='-'){ //The only intentionally unsavory chars we're told we'll have to deal with are space and dash
garbagechars++; //counts the number of spaces and dashes the user inputs
}
}
if ((phone_word.length()-garbagechars) < 7) //the length of vital characters
{
cout << "Insufficient string length. Please re-enter a string of at least 7 characters: \n";
format_correct = false;
}
else
{
format_correct = true;
}
}
outcounter=0;
incounter=0;
while(outcounter < 8){
letter = phone_word[incounter];
if(outcounter==0){
cout<<"\nThe corresponding number is: " << endl;
}
if(outcounter==3){
cout << '-';
outcounter++;
}
switch(letter)
{
case'0':
cout << 0;
incounter++;
outcounter++;
break;
case'1':
cout << 1;
incounter++;
outcounter++;
break;
case'a': case'A': case'b': case'B': case'c': case'C': case'2':
cout << 2;
incounter++;
outcounter++;
break;
case'd': case'D': case'e': case'E': case'f': case'F': case'3':
cout << 3;
incounter++;
outcounter++;
break;
case'g': case'G': case'h': case'H': case'i': case'I': case'4':
cout << 4;
incounter++;
outcounter++;
break;
case'j': case'J': case'k': case'K': case'l': case'L': case'5':
cout << 5;
incounter++;
outcounter++;
break;
case'm': case'M': case'n': case'N': case'o': case'O': case'6':
cout << 6;
incounter++;
outcounter++;
break;
case'p': case'P': case'q': case'Q': case'r': case'R': case's': case'S': case'7':
cout << 7;
incounter++;
outcounter++;
break;
case't': case'T': case'u': case'U': case'v': case'V': case'8':
cout << 8;
incounter++;
outcounter++;
break;
case'w': case'W': case'x': case'X': case'y': case'Y': case'z': case'Z': case'9':
cout << 9;
incounter++;
outcounter++;
break;
case' ': case '-':
incounter++;
break;
default: cout << "\nInvalid input." << endl;
outcounter=8;
}
}
cout << endl << endl;
while (!yornctrl){
string resp="";
cout << "Do you want to enter another number? [Yy]es [Nn]o: ";
cin>>resp;

if(resp[0] == 'Y' || resp[0] == 'y') {
loop_ctrl = true;
cin.get();
yornctrl=true;
}
else if(resp[0] == 'N' || resp[0] == 'n')
{
loop_ctrl = false;
cout << "Goodbye\n";
yornctrl=true;
}else yornctrl = false;
}
}while(loop_ctrl);
system("pause");
return 0;
}

David_3033
10-09-2012, 12:07
Wow you guys have been extremely helpful with this assignment! I thank you both very much!!

Ragingclue
10-09-2012, 12:09
No problem.

I had to edit that last code I posted, the default case for the letter switch had not been done correctly. It's good now.

David_3033
10-09-2012, 13:40
I would buy you a beer if I could.

Ragingclue
10-09-2012, 13:50
Well if you do end up getting the chance some day, that would be cool too.

I really need to brush up on my string object. I think there is probably a better way to parse the string at first for garbage and then length. But it is really fun sometimes to realize just how much you've forgotten over time.

And like I said, it's not completely formatted (we generally use Allman but it's not strictly enforced), and there could be a bomb or leak in there waiting to F with you after you turn it in, but I tried to run as many weird cases through it as I could. It's not polished at that point, but it works for the most part. If you find a condition that breaks it, let me know.

Ragingclue
10-09-2012, 14:14
Damn realized I was resetting garbagechars in the wrong place. This would cause it to not reset after each string parsing, if the findings were that the string was already too short. I would have left well enough alone but that's a pretty big oversight. Here's what I got now, only changes are up top with the declarations and string parsing.


#include <iostream>
#include <string>

using namespace std;

int main(){
bool yornctrl, format_correct, loop_ctrl=true;
int garbagechars, outcounter, incounter;
string phone_word;
char letter, redo;
do{
yornctrl=false;
format_correct=false;
cout << "Enter the letters you would like to convert to a phone number:" << endl;
while(!format_correct){
garbagechars=0;
phone_word = "supercalafragilisticexpealidocious";
getline(cin, phone_word);
for(int i=0; i<phone_word.length(); i++){
if (phone_word[i]==' ' || phone_word[i]=='-'){ //the only chars we'll skip over are space and dash
garbagechars++; //counts the number of spaces and dashes the user inputs
}
}
if ((phone_word.length()-garbagechars) < 7) //the length of vital characters
{
cout << "Insufficient string length. Please re-enter a string of at least 7 characters: \n";
format_correct = false;
}
else
{
format_correct = true;
}
}
outcounter=0;
incounter=0;
while(outcounter < 8){
letter = phone_word[incounter];
if(outcounter==0){
cout<<"\nThe corresponding number is: " << endl;
}
if(outcounter==3){
cout << '-';
outcounter++;
}
switch(letter)
{
case'0':
cout << 0;
incounter++;
outcounter++;
break;
case'1':
cout << 1;
incounter++;
outcounter++;
break;
case'a': case'A': case'b': case'B': case'c': case'C': case'2':
cout << 2;
incounter++;
outcounter++;
break;
case'd': case'D': case'e': case'E': case'f': case'F': case'3':
cout << 3;
incounter++;
outcounter++;
break;
case'g': case'G': case'h': case'H': case'i': case'I': case'4':
cout << 4;
incounter++;
outcounter++;
break;
case'j': case'J': case'k': case'K': case'l': case'L': case'5':
cout << 5;
incounter++;
outcounter++;
break;
case'm': case'M': case'n': case'N': case'o': case'O': case'6':
cout << 6;
incounter++;
outcounter++;
break;
case'p': case'P': case'q': case'Q': case'r': case'R': case's': case'S': case'7':
cout << 7;
incounter++;
outcounter++;
break;
case't': case'T': case'u': case'U': case'v': case'V': case'8':
cout << 8;
incounter++;
outcounter++;
break;
case'w': case'W': case'x': case'X': case'y': case'Y': case'z': case'Z': case'9':
cout << 9;
incounter++;
outcounter++;
break;
case' ': case '-':
incounter++;
break;
default: cout << "\nInvalid input." << endl;
outcounter=8;
}
}
cout << endl << endl;
while (!yornctrl){
string resp="";
cout << "Do you want to enter another number? [Yy]es [Nn]o: ";
cin>>resp;

if(resp[0] == 'Y' || resp[0] == 'y') {
loop_ctrl = true;
cin.get();
yornctrl=true;
}
else if(resp[0] == 'N' || resp[0] == 'n')
{
loop_ctrl = false;
cout << "Goodbye\n";
yornctrl=true;
}else yornctrl = false;
}
}
while(loop_ctrl);
system("pause");
return 0;
}

David_3033
10-09-2012, 20:38
Since you guys are pretty good at C++, do you know of any really good tutorials on the web that you could point me to? Video and where they have the code written out in a small example usually helps me learn it the best. I have been using newboston for most my video help. They are pretty good and he makes them easy to understand. If you know of other sites like the below link.

http://thenewboston.org/list.php?cat=16

David_3033
10-09-2012, 21:46
I copied and pasted your code just as you had it Ragingclue and I got two errors. Do you know what these errors are? I am using visual studio express 2010.

error LNK2001: unresolved external symbol_mainCRTStartup
error LNK1120: 1 unresolved externals

iamthesgt
10-09-2012, 23:13
Since you guys are pretty good at C++, do you know of any really good tutorials on the web that you could point me to? Video and where they have the code written out in a small example usually helps me learn it the best. I have been using newboston for most my video help. They are pretty good and he makes them easy to understand. If you know of other sites like the below link.

http://thenewboston.org/list.php?cat=16

I never used video to help me learn, although that may have made it easier. Best help I got was on stackoverflow.com - but make sure you read the FAQ before you ask questions!

Ragingclue
10-10-2012, 09:12
I copied and pasted your code just as you had it Ragingclue and I got two errors. Do you know what these errors are? I am using visual studio express 2010.

error LNK2001: unresolved external symbol_mainCRTStartup
error LNK1120: 1 unresolved externals

Does it need to be a Windows application, or will a console application do? If console is OK:
Right-click the project name-->Properties-->Configuration Properties-->Linker-->System-->SubSystem --> set to Console (/SUBSYSTEM:CONSOLE)

If that doesn't work, don't paste into your existing project, start a new one:
File->New->Project then in dialog select Win32 and on the right side Win32 Console Application, and make sure to check "Empty Project". Right click the Source Files folder in the Solution Explorer on the left of the screen (assuming default setup). Add-->New Item. Select C++ File (.cpp). Name that file main or whatever you want.

Paste code into new file. Save All. Build. Debug.

That should do it. Does a simple console application fit the requirement?

iamthesgt
10-10-2012, 09:43
I copied and pasted your code just as you had it Ragingclue and I got two errors. Do you know what these errors are? I am using visual studio express 2010.

error LNK2001: unresolved external symbol_mainCRTStartup
error LNK1120: 1 unresolved externals

This is for a college class, right? You can get the full VisualStudio if you want it from Microsoft through Dreamspark. Not that it would probably make difference for what you're doing. I prefer Eclipse for C++ development anyway.

David_3033
10-10-2012, 10:22
I did the dreamspark thing and the download was giving me issues. So now I use the express and that has been working fine.