in the String class for java, I believe there is a function .toChar() or something. Well what that does is it turns the String into a char[]
A string in C, is comprised of just an array of characters, there is no class in C.
>Terminated by a NULL character ('\0')
>Without the NULL character, it is just an array of characters, C will not recognize it as a String without the NULL
>Thanks Quzah
if your a beginner to C, try to avoid dynamic strings (strings where you change the size of it)
and go ahead and be wasteful of memory like
and to use strings, you can't just say
myStr = "hi";
there is a function in string.h to assign Literal strings (strings int he quotes) to the character array
prototype:
Code:
int strcpy(char* destination, char* cpyString);
lets say you allocate some memory for a string and then you want to put Hello world in it, you can do this many ways, here are some:
Code:
1:
char *str = "Hello, World\n";
2:
char str[] = "Hello, World\n";
3:
char str[256];
strcpy(str,"Hello, World\n");
just remember that arrays are treated as pointers and similar. Please read the FAQ for more details.
-LC