Cannot compare pointers to strings?


by dE_logics
Tags: compare, pointers, strings
dE_logics
dE_logics is offline
#1
Sep6-09, 10:14 PM
P: 730
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
Cougars' diverse diet helped them survive the Pleistocene mass extinction
Cyber risks can cause disruption on scale of 2008 crisis, study says
Mantis shrimp stronger than airplanes
Hurkyl
Hurkyl is offline
#2
Sep6-09, 10:46 PM
Emeritus
Sci Advisor
PF Gold
Hurkyl's Avatar
P: 16,101
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
dE_logics is offline
#3
Sep7-09, 12:25 AM
P: 730
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