Top "C-strings" questions

A string in the programming language C is represented as a sequence of characters followed by a null terminator (represented as \0).

How do you convert CString and std::string std::wstring to each other?

CString is quite handy, while std::string is more compatible with STL container. I am using hash_map. However, hash_…

c++ mfc c-strings stdstring
Strip first and last character from C string

I have a C string that looks like "Nmy stringP", where N and P can be any character. How can …

c string c-strings
Converting String to Cstring in C++

I have a string to convert, string = "apple" and want to put that into a C string of this style, …

c++ string c-strings
C - split string into an array of strings

I'm not completely sure how to do this in C: char* curToken = strtok(string, ";"); //curToken = "ls -l" we will say //…

c c-strings
String termination - char c=0 vs char c='\0'

When terminating a string, it seems to me that logically char c=0 is equivalent to char c='\0', since …

c string c-strings null-terminated ansi-c
Is it possible to print out only a certain section of a C-string, without making a separate substring?

Say I have the following: char* string = "Hello, how are you?"; Is it possible to print out only the last 5 …

c printf c-strings
Why do I get a segmentation fault when writing to a "char *s" initialized with a string literal, but not "char s[]"?

The following code receives seg fault on line 2: char *str = "string"; str[0] = 'z'; // could be also written as *str = 'z' …

c segmentation-fault c-strings
Using C-string gives Warning: "Address of stack memory associated with local variable returned"

I am not a C programmer, so I am not that familiar with C-string but now I have to use …

c++ pointers c-strings
How to extract a substring from a string in C?

I tried using strncmp but it only works if I give it a specific number of bytes I want to …

c string c-strings
How can I check if a string has special characters in C++ effectively?

I am trying to find if there is better way to check if the string has special characters. In my …

c++ string whitelist c-strings