Click here to Skip to main content
15,903,012 members
Everything / char

Char

char

Great Reads

by ToughDev
How to convert between NSString and C strings in iOS project
by Nemanja Trifunovic
Purpose, history and scenarios of use of character data types

Latest Articles

by ToughDev
How to convert between NSString and C strings in iOS project
by Nemanja Trifunovic
Purpose, history and scenarios of use of character data types

All Articles

Sort by Updated

char 

20 Feb 2023 by Addy__0
#include #include #include int main() { char **Str; Str= (char**)calloc(20,sizeof(char)); Str[0]= (char*) calloc(10, sizeof(char)); Str[0]= "Hello, world"; printf("%s", *(Str+0)); } What I have...
18 Feb 2023 by Addy__0
#include #include #include char **StringArray(char **arr, int size); int main() { char **Str; int n= 5; int i; Str= (char**)calloc(5,sizeof(char)); Str[0]= (char*) calloc(10, sizeof(char)); ...
17 Feb 2023 by CPallini
Quote: Str= (char**)calloc(5,sizeof(char)); That should beStr= (char**)calloc(5,sizeof(char *)); Might be there are other errors, as well. Anyway the code is not robust against user input.
20 Feb 2023 by Fred van Lieshout
Just keep in mind that everything takes up memory, including pointers. It can be handy to let a pointer (to a pointer) point to something else. Also, the line where memory is allocated to store the actual string, is not needed. Str[0]= (char*)...
18 Feb 2023 by merano99
Currently, this is C source code. The other programming languages according to the tag are irrelevant. There are several errors: // Str = (char**)calloc(5, sizeof(char)); need space for pointer, use n for size! Str = (char**)calloc(n,...
25 Nov 2022 by Nemanja Trifunovic
Purpose, history and scenarios of use of character data types
17 Feb 2023 by OriginalGriff
You allocate a block of memory (20 chars worth) and tell the system that that is a set of pointers to chars - because Str is a pointer to a pointer to a char. Which is effectively a pointer to a string. Think of Str as a array of pointers to...
17 Feb 2023 by OriginalGriff
Probably because it doesn't compile: you declare StringArray as returning achar** - but the function body does not have a return statement. If code doesn't compile, then it doesn't generate an EXE file - so what you are running is the previous...
8 May 2023 by ToughDev
How to convert between NSString and C strings in iOS project