Link to home
Start Free TrialLog in
Avatar of SuperSid
SuperSid

asked on

New to C++. Need to know how to use a string.

How do i use a string?

I did #include <string.h>

but when i do

string x = "hello world";
cout<<x;

it's an error.. said "string" is an undeclared identifier..

I'm just really new to programming and don't even know how to use a string.

I'm trying to get the user to enter a number of words and then use if-then form to create a game for my final project.

thx
Avatar of SuperSid
SuperSid

ASKER

might i add that this is my code.

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




int main (void)
{
     
     string x = "hello world";
     cout<<x<<"\n";



}

error:  'string' : unidentified modifier.
try using:

#include <string>

instead of

#include <string.h>

you also might want to check out this link:
http://www.amberman.org/evolve/Software/strings/
ASKER CERTIFIED SOLUTION
Avatar of bobbit31
bobbit31
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial