Why is strcmp not working.....

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream.h>
#include<conio.h>
#include<string.h>
char *t1,*t2;
void main()
{
clrscr();
cin>>t1;
cin>>t2;
if(strcmp(t1,t2)==0)
cout<<"HEllo";
else
cout<<"NO hello";
getch();
}


The value is always true for any value of t1 and t2

if i write

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include<iostream.h>
#include<conio.h>
#include<string.h>
void main()
{
clrscr();
char *t1,*t2;
cin>>t1;
cin>>t2;
if(strcmp(t1,t2)==0)
cout<<"Hello";
else
cout<<"No hello";
getch();
}


It works properly....
Why so??
PS: I have to use Borland C++/Turbo C++
Both programs are incorrect. You must make t1 and t2 point to the memory where you want the input to be written.
Topic archived. No new replies allowed.