How can I fix this so it will let me compare the two?

note, the error is at the for loop.

string Socket::Recv() {
	
	/* Get socket size before recv'ing */
	while (size == 0)
		ioctlsocket(client, FIONREAD, &size);
                        
	/* Create a 'string (characters)' the size of the information being recv in order to add \0 for string conversion */
	char *msg = new char[size + 1];
                
	/* Recv information that the socket is sending us */
	length = recv(client, msg, size, 0);
                
	/* Put into an empty string  */
 	msg[size] = '\0';
 	
 	
 	for (int i = 0; i < msg[size]; i++) {
		if(msg[i] == ":") {
			msg[i] == "";
		}
 	}
                
 	/* Output message, and destroy possile Memory leak */
	cout << msg;
	delete[] msg; 
}

I can't see where are you comparing a pointer and an int.
In the loop condition, msg is a char and i is an integer. Pretty legal.
msg is having value 0. So I guess the loop would never execute.

PS: If your compiler is generating any error, please post it along.

He's comparing an int to a pointer at line 18. And assigning a pointer to an int at line 19.
Changing double quotes to single quotes (at line 18 and 19) would help.

Oh, I never saw that. Great,
But still, your loop won't work because of the said reasons.

Oh, I never saw that. Great,
But still, your loop won't work because of the said reasons.

Oh, I never saw that. Great,
But still, your loop won't work because of the said reasons.

Compiling...
In file included from main.h:6,
                 from main.cpp:8:
net/socket.cpp: In member function `std::string Socket::Recv()':
net/socket.cpp:83: error: ISO C++ forbids comparison between pointer and integer

net/socket.cpp:84: error: ISO C++ forbids comparison between pointer and integer

Press any key to continue . . .

83 and 84 is line 18... I even removed the msg = "\0" but still, the same error. I tried turning it into an string, still, same error.

I changed the "" to '', and it worked, why, exactly?

Any character in single quote has type of char.
Double quotes are used for string. They have type const char* that is pointer to char (whole values can't be changed).
So, "a" is actually an array of two elements : 'a' and '\0'

Any character in single quote has type of char.
Double quotes are used for string. They have type const char* that is pointer to char (whole values can't be changed).
So, "a" is actually an array of two elements : 'a' and '\0'

ooooh, I get it. Thank you

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.