Home | Gallery | Forum | Services | Webmail | Archive | Links | Contact Us | About Us
OS2 World.Com Forum
OS2 World.Com Online Discussion Forum.
Index / OS/2 - General / Programming
author message
Newbie problem - String Class
Post a new topic Reply to this Topic Printable Version of this Topic Forward this Topic to your Friend Topic Commands (for administrator or moderators only)
JGiacchi
Normal member
in user

View this member's profileSearch all posts from this memberSend an email to this member
posts: 9
since: 22 Sep, 2002
1. Newbie problem - String Class
Reply to this topic with quote Modify your message
I'm in a Comp Sci class at my high school and I'm trying to get a string to work. This is my program. My compiler is IBM Visualage 4.0 and the error i get is "MSG CPPC0063E: The text"{" is unexpected." Any help you could give me would be greatly appreciated.

#include <iostream.h>
#include <string.h>

void verse(string lanimal, string lsound)
{
cout << "Old MacDonald had a farm Ei Ei Ho and on that farm he had a " << ;
cout << lanimal << "Ei Ei Ho" << endl;
cout << "With a " << lsound << " " << lsound <<"here and a " << lsound << " " << lsound << "there." <<endl;
cout << "Here a " << lsound << "there a " << lsound << "everywhere a " << lsound << " " << lsound << "." <<endl
cout << "Old MacDonald had a farm Ei Ei Ho" << endl;
}
int main(string ganimal, string gsound)
{
cin >> ganimal;
cin >> gsound;
verse(gsound,ganimal);
return 0;
}


Build FIRST, ask questions later.
Date: 22 Sep, 2002 on 22:56
JasonL
Normal member
in user

View this member's profileSearch all posts from this memberSend an email to this memberhttp://home.houston.rr.com/luedke
posts: 21
since: 10 Jun, 2001
2. Re:Newbie problem - String Class
Reply to this topic with quote Modify your message
Correct me if I'm wrong, but I don't believe "string" is a valid data type in C / C++

Strings need to be declared in one of 2 ways:

1. An array of char 's: char lanimal[10];
2. a char pointer: char *lanimal;

This is assuming you did not create a user-defined type called "string" elsewhere in the code. I'm also not sure how using the wrong data type declaration would produce the error message you're getting.

Hope this helps.
JasonL

Date: 23 Sep, 2002 on 19:55
JGiacchi
Normal member
in user

View this member's profileSearch all posts from this memberSend an email to this member
posts: 9
since: 22 Sep, 2002
3. Re:Newbie problem - String Class
Reply to this topic with quote Modify your message
That did help thanks a lot.
Build FIRST, ask questions later.
Date: 24 Sep, 2002 on 05:07
Newbie problem - String Class
Post a new topic Reply to this Topic Printable Version of this Topic Forward this Topic to your Friend Topic Commands (for administrator or moderators only)
All times are CET+1. < Prev. | P. 1 | Next >
Go to:
 

Powered by UltraBoard 2000 Standard Edition,
Copyright © UltraScripts.com, Inc. 1999-2000.
Home | Gallery | Forums | Services | Webmail | Archive | Links | Contact Us | About Us
OS2 World.Com 2000-2004