i am a 13 year old stuck at this, someone please help me out!!


i have a problem defining a character variable



its giving the error lvalue required


#include <iostream.h>
#include <conio.h>

void main()
{
clrscr();

char name [20];

cin >>" Your name please...", name;

if (name="john")   //over here!!!

cout <<"hi ", name;

else
cout <<"sorry!";
}

Character arrays can not be compared like that. Either use std::string instead of char or call strcmp() to compare the two strings. if( strcmp(name,"John") == 0) strcmp() returns 0 if the two strings are the same.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.