0

Hi all:
Got a formatting question here:
Trying to send data string over to a server via send();
The problem is that I want to enclose the data string with double-quotes, "data string" should be displayed on the server side. The method I used is using two double_quotes on each end of the data string, writing the string with the double_quotes to another string and lastly, send the second string using send(). However, the result is the data string without the double quotes I added? Why?

Codes:

_snprintf(user_message,MESSAGE_LINE_SIZE, "MESSAGE ""%s""\r",s);
send(sock,user_message,(int)strlen(user_message),0)==SOCKET_ERROR)

Thanks

3
Contributors
4
Replies
5
Views
11 Years
Discussion Span
Last Post by yuzhang
0

>>"MESSAGE ""%s""\r"
The reason this doesn't work the way you want it is because that is a standard way of concantinating string literals and the compiler will just make one string out of it.

char str[] = "Hello " "World"
is the same as this
char str[] = "Hello World"

0

Hi dragon, good to see you again.
Thanks for you info, I always learn something new from you.
Thank you again.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.