im very new to programming also but i dont think you can assign a string the
same as other languages
im sure a million people will correct me on this but try this
//---------------------------------------------------------------------------
#include <clx.h>
#pragma hdrstop
#include <iostream.h>
#include <string.h>
using namespace std;
int main()
{ char name[20];// makes a char array of 20 elements
cout << "Please enter your name ";
gets(name);//gets accepts spaces and sends value to name array once carraige
return is pressed
if (name == "John")
{
cout << "Your name is John ";
}
else
{
cout << "Your name is not John ";
}
system("pause");
return 0;
}
>From: "len_kim" <[EMAIL PROTECTED]>
>Reply-To: [email protected]
>To: [email protected]
>Subject: [c-prog] Evaluating Strings
>Date: Sun, 04 Mar 2007 22:11:16 -0000
>
>Hello,
>
>I am brand new to programming and am currently attempting to learn
>C++.
>I am unable to get the below program to evaluate the string that is
>entered for the name. Can someone tell me what I am doing wrong and
>if it is even possible to run an "if" statement and make it evaluate
>a string?
>
>#include <iostream>
>#include <string>
>using namespace std;
>int main()
>{ string name;
>cout << "Please enter your name ";
>cin >> name;
>if (name == 'John')
>cout << "Your name is John ";
>else
>cout << "Your name is not John ";
>return 0;
>}
>
_________________________________________________________________
With tax season right around the corner, make sure to follow these few
simple tips.
http://articles.moneycentral.msn.com/Taxes/PreparationTips/PreparationTips.aspx?icid=HMFebtagline