Click here to Skip to main content
15,889,724 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 Score

char 

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...
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.
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...
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,...
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*)...
8 May 2023 by ToughDev
How to convert between NSString and C strings in iOS project
25 Nov 2022 by Nemanja Trifunovic
Purpose, history and scenarios of use of character data types