ProWrestling Fans WWE TNA Forum

Go Back   ProWrestling Fans WWE TNA Forum > ProWrestlingFans > Archives

Archives PWFans Forums Archives - Where all the old threads go...

Anyone here know anything about C++?
 
 
LinkBack Thread Tools Display Modes
Old 07 Oct 2002, 10:30 AM   #1 (permalink)
afficial
Guest
 
Posts: n/a
Default Anyone here know anything about C++?

I need help writing a code for school, so if anyone here knows how to program a little in c++ pleeeeeease help.
 
Old 07 Oct 2002, 10:38 AM   #2 (permalink)
Seeing the world explode
 
Max Cannon's Avatar
 
Join Date: Aug 2002
Location: Nova Scotia
Posts: 1,807
Rep Power: 18
Max Cannon is on a distinguished road
Send a message via AIM to Max Cannon
Default

Man, I would like to help u..but I had no room in my schedule for any comp courses...Damned Physics, Bio, and Chem.
Max Cannon is offline  
Old 07 Oct 2002, 10:57 AM   #3 (permalink)
afficial
Guest
 
Posts: n/a
Default

ah it's alright man, thanks anyways.
 
Old 07 Oct 2002, 02:02 PM   #4 (permalink)
Version 4.7
 
Calvin's Avatar
 
Join Date: Sep 2002
Location: San Dimas High School (Scotland)
Posts: 884
Rep Power: 17
Calvin is on a distinguished road
Default

I'm studying C++ at college just now, but all I know is cout, cin and strings, might be able to help though.
Calvin is offline  
Old 07 Oct 2002, 02:07 PM   #5 (permalink)
afficial
Guest
 
Posts: n/a
Default

Ok Calvin, i'm probably at the same state as you because i'm just leaning it too.

I need to make a code that accepts 20 characters and then converts them to all uppercase.

Here's my code i wrote but i keep getting an error, see if you can spot something wrong.


#include <iostream>
#include <ctype.h>
using namespace std;

void main ()

{
cout << "Please input your twenty character long string then press <enter>:" << endl;
int upperCount = 0;
char ch;
cin.get(ch);

for(int i = 1; i <= 20; i++)
{cout << i << endl;
}
for(int i = 1; i <= 20 && ch != '\n'
{
if (isupper(ch))
{
upperCount++;
}
cin.get(ch);
}

cout << "There were " << upperCount << "number of upper case characters." << endl;

cout << "Press Enter to Continue..";
cin.ignore(100,'/n');

}
 
Old 07 Oct 2002, 02:08 PM   #6 (permalink)
afficial
Guest
 
Posts: n/a
Default

btw that winking smiley is not supposed to be there
 
Old 07 Oct 2002, 02:09 PM   #7 (permalink)
Version 4.7
 
Calvin's Avatar
 
Join Date: Sep 2002
Location: San Dimas High School (Scotland)
Posts: 884
Rep Power: 17
Calvin is on a distinguished road
Default

ahh I did this a few weeks ago.. somethign to do with strings I think, i'll see if I can find the coding then edit this post
Calvin is offline  
Old 07 Oct 2002, 02:10 PM   #8 (permalink)
afficial
Guest
 
Posts: n/a
Default

THANKS!!!!! If you get it to work you will be my idol.
 
Old 07 Oct 2002, 02:11 PM   #9 (permalink)
DC
I've got the power!
 
DC's Avatar
 
Join Date: Aug 2002
Location: Georgia
Posts: 15,838
Rep Power: 3194
DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.DC , get a rope and a stool and a REALLY solid beam.  Fatso.
Send a message via MSN to DC
Default

I know this doesn't help but i have no fuckin clue to what you are doing
__________________
looking for my sig? look harder!
DC is offline  
Old 07 Oct 2002, 02:13 PM   #10 (permalink)
Version 4.7
 
Calvin's Avatar
 
Join Date: Sep 2002
Location: San Dimas High School (Scotland)
Posts: 884
Rep Power: 17
Calvin is on a distinguished road
Default

heh this could take a little longer than expect, (we have to code some stuff a little diffrently in class) I'll do my program again and see what's up
Calvin is offline  
Old 07 Oct 2002, 02:16 PM   #11 (permalink)
afficial
Guest
 
Posts: n/a
Default

Alright cool, thanks man.

It has to include the loop though, it's a requirement
 
Old 07 Oct 2002, 02:31 PM   #12 (permalink)
Version 4.7
 
Calvin's Avatar
 
Join Date: Sep 2002
Location: San Dimas High School (Scotland)
Posts: 884
Rep Power: 17
Calvin is on a distinguished road
Default

um.. are you declare your procedures (void)? and the indentifiers?

in college we did

void key_in_first_name()
{
cout << "Please enter your first name = ";
cin >> firstname;
for (count = 0; count < 18; count++)
{
firstname[count] = toupper (firstname[count]);
}
}

then we kinda did the same for initial and surname changing the data as required

you might need to try change

if (isupper(ch))

to

if (toupper(ch))

your loop does look right though, well the part of it that I understood anyway
Calvin is offline  
Old 07 Oct 2002, 02:40 PM   #13 (permalink)
afficial
Guest
 
Posts: n/a
Default

Um, we always just put "void main ()" we never learned as to what it does so i'm not sure.

I changed the isupper to toupper but didn't chage

Also the error i get says this: error C2374: 'i' : redefinition; multiple initialization
C:\Program Files\Ftp\upper2.cpp(20) : see declaration of 'i'

If you know what that means
 
Old 07 Oct 2002, 02:53 PM   #14 (permalink)
Version 4.7
 
Calvin's Avatar
 
Join Date: Sep 2002
Location: San Dimas High School (Scotland)
Posts: 884
Rep Power: 17
Calvin is on a distinguished road
Default

I have an idea, I think it means your not declaring what "i" is so the compiler has no idea what your saying

basically the whole program looked like

char firstname [18];
char initial [3];
char surname [20];
int count;

void key_in_first_name();
void key_in_initial();
void key_in_surname();
void print_out_full_name();


void main()
{
Setupio();

key_in_first_name();
key_in_initial();
key_in_surname();
print_out_full_name();
}


void key_in_first_name()
{
cout << "Please enter your first name = ";
cin >> firstname;
for (count = 0; count < 18; count++)
{
firstname [count] = toupper (firstname [count]);
}
}


void key_in_initial()
{
cout << "Please enter your middle initial = ";
cin >> initial;
for (count = 0; count < 3; count++)
{
initial [count] = toupper (initial [count]);
}
}


void key_in_surname()
{
cout << "Please enter your surname = ";
cin >> surname;
for (count = 0; count < 20; count++)
{
surname [count] = toupper (surname[count]);
}
}


void print_out_full_name()
{
cout << "Your name is ";
cout << firstname << " ";
cout << initial << " ";
cout << surname;
cout << endl;
}

things like upcount20 and i need to be identified so the computer knows what they are when it compiles

also in the error section if you click on the error message it will show you the part of the program it doesn't understand with a blue arrow
Calvin is offline  
Old 07 Oct 2002, 02:58 PM   #15 (permalink)
afficial
Guest
 
Posts: n/a
Default

Ahh thanks for the tip with the blue arrow, never knew that.

I know it doesnt undertsand the definition of "i" but to declare it don't i just do

int i;

?

But when i put that in i get more errors.
And when i look at your i just get more lost.

Did you try putting my code into your prog and try it?
 
 


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT -5. The time now is 02:38 PM.

Attribution:
Powered by Yahoo Answers



Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO 3.6.0 PL2 © 2011, Crawlability, Inc.