In visual basic I have the following 2 strings:
"\\.\" & "\"
How do I represent them in C?
Also, &
in VB is the concatenation operator?
In visual basic I have the following 2 strings:
"\\.\" & "\"
How do I represent them in C?
Also, &
in VB is the concatenation operator?
The \
is an escape character so if you want to print \
you need to put two of them: \\
To concatenate two string you can use strcat(string1, string 2) which is shown here.
As others have said, the backslash character () in C is an escape character. Look at http://msdn.microsoft.com/en-us/library/h21280bw%28VS.80%29.aspx to find more about it.
So your strings come out as follows:
"\\.\" is "\\\\.\\"
"\" is "\\"
There are many ways to concatenate strings.
puts("Hello" " " "World");
will print "Hello World".
A common way is to use strcat().
char szBuff[60]; /* szBuff is an array of size 60 */
strcpy(szBuff, "Hello"); /* szBuff contains "Hello" */
strcat(szBuff, " World"); /* szBuff contains "Hello World" */
strcat(szBuff, " from Michael"); /* now contains the whole sentence */
strcpy(szBuff, "New message"); /* strcpy overwrites the old contents */