conversion const char* to int

What do you think the following line is doing?

first1 == "||:::" ;

What type is first1?

What type is "||:::"?

What does the == operator do?
Last edited on
One problem is a pattern in this code. Picking one instance:
1
2
  if (	first	 ==	0	)
	first1	==	"||:::"	;


first1 is an int
"||:::" is a const char *

You cannot assign a const char * to an int.

"==" compares two things and returns a bool.
You want to use "=" for an assignment.

To start with, I suggest you define first1 and friends as std::string. Something like
1
2
3
4
string first1;
...
if (first == 0)
    first1 = "||:::";

"81 12 [Error] ISO C++ forbids comparison between pointer and integer [-fpermissive]"
"85 9 [Error] invalid conversion from 'const char*' to 'int' [-fpermissive]" and i don't know how to fix it.

The first number I believe is the line number.
So look at Line 81 and 85 to begin.

I already see the problem, do you ? Compare these lines

1
2
3
4
   if (	first	 ==	0	)
	first1	==	"||:::"	;
else if (	first	 ==	1	)
	first1	=	":::||"	;



Actually I see a second problem. Look at the line below then the lines above.

int checkdigit1,first1, second1, third1, fourth1, fifth1,first, second, third, fourth, fifth, sum=0, checkdigit, zipcode;
Last edited on
Please DON'T delete your question after you've gotten an answer. It makes the thread useless as a learning resource for others. It's a selfish abuse of this forum.
Topic archived. No new replies allowed.