Register to reply

Cannot compare pointers to strings?

by dE_logics
Tags: compare, pointers, strings
Share this thread:
dE_logics
#1
Sep6-09, 10:14 PM
P: 735
After compiling the code below, GCC says that you can't compare a pointer to string by iso C++ standards.

But I don't see a pointer anywhere (I don't know pointers for now...did it long ago, now forgot)...may be it has to do with the fact that arrays are called by reference.

char convert(unsigned char input[]);
main()
{
	unsigned char input[1000];
	convert(input);
}
char convert (unsigned char input[])
{
	int i;
	if(input[0] == " ");
}
Phys.Org News Partner Science news on Phys.org
Security CTO to detail Android Fake ID flaw at Black Hat
Huge waves measured for first time in Arctic Ocean
Mysterious molecules in space
Hurkyl
#2
Sep6-09, 10:46 PM
Emeritus
Sci Advisor
PF Gold
Hurkyl's Avatar
P: 16,092
Quote Quote by dE_logics View Post
if(input[0] == " ");
input[0] has type unsigned char&.
" " has type const char*.

You meant ' ' which has type char.
dE_logics
#3
Sep7-09, 12:25 AM
P: 735
Oh...damn...I meant single quotes. :P


Register to reply

Related Discussions
Converting open strings to closed strings Beyond the Standard Model 4
Pointers not allowed to used iostream Programming & Computer Science 4
Coding a Bubble Sort routine using a pointer array Programming & Computer Science 4
New and looking for pointers. General Discussion 0
Siemens fc10 to compare 2 strings Electrical Engineering 1