As I can understand from your assignment statement in while loop I think you need array of strings instead:
char** new_array; new_array = malloc(30 * sizeof(char*)); // ignore casting malloc
Note: By doing =
in while loop as below:
new_array [i] = new_message->array_pointers_of_strings [i];
you are just assigning address of string (its not deep copy), but because you are also writing “only address of strings” so I think this is what you wants.
Edit: waring “assignment discards qualifiers from pointer target type”
you are getting this warning because you are assigning a const char*
to char*
that would violate the rules of const-correctness.
You should declare your new_array like:
const char** new_array;
or remove const
in declaration of ‘array_pointers_of_strings’ from message stricture.
Related Posts:
- How to properly malloc for array of struct in C
- How to initialize array to 0 in C?
- difference between
and - Convert char array to a int number in C
- Returning an array using C
- Use of cudamalloc(). Why the double pointer?
- Incorrect checksum for freed object on malloc
- How to copy a char array in C?
- C subscripted value is neither array nor pointer nor vector when assigning an array element value
- Difference between sizeof(char) and sizeof(char *)
- struct has no member named
- Initializing array of structures
- How to empty a char array?
- What is the difference between array and enum in C ?
- Can I create an Array of Char pointers in C?
- Excess elements of scalar initializer for pointer to array of ints
- typedef fixed length array
- realloc(): invalid next size when reallocating to make space for strcat on char *
- C: warning: excess elements in array initializer; near initialization for ‘xxx’ ; expects ‘char *’, but has type ‘int’
- Pointer to 2D arrays in C
- Initializing 2D char array in C
- How do I check if a string contains a certain character?
- malloc(sizeof(int)) vs malloc(sizeof(int *)) vs (int *)malloc(sizeof(int))
- How do I create an array of strings in C?
- “Expected expression before ‘ { ‘ token”
- C pointers and arrays: [Warning] assignment makes pointer from integer without a cast
- How to print the array?
- “error: assignment to expression with array type error” when I assign a struct field (C)
- Getting “conflicting types for function” in C, why?
- How do you make an array of structs in C?
- Is there a function to copy an array in C/C++?
- Why am I getting “array initializer must be an initializer list or string literal”?
- Incompatible implicit declaration of built-in function ‘malloc’
- How to make an array with a dynamic size? General usage of dynamic arrays (maybe pointers too)?
- Need more information about Aborted (core dumped)
- What is the cause of flexible array member not at end of struct error?
- waitpid, wnohang, wuntraced. How do I use these
- Warning: assignment from incompatible pointer type
- How do malloc() and free() work?
- C: error: expected ‘)’ before ‘;’ token
- I’m getting “Invalid Initializer”, what am I doing wrong?
- Data argument not used by format strings in C
- execv vs execvp, why just one of them require the exact file’s path?
- Warning/error “function declaration isn’t a prototype”
- warning: initializer element is not computable at load time
- How to prevent multiple definitions in C?
- How can you print multiple variables inside a string using printf?
- Flushing buffers in C
- What are 0x01 and 0x80 representative of in C bitwise operations?
- Convert char array to string use C
- How to make parent wait for all child processes to finish?
- Undefined Reference issues using Semaphores
- What is time(NULL) in C?
- C dynamically growing array
- Why should we check WIFEXITED after wait in order to kill child processes in Linux system call?
- OpenGL — GL_LINE_LOOP —
- How to use EOF to run through a text file in C?
- Valgrind complains with “Invalid write of size 8”
- Expression must be a pointer to a complete object type using simple pointer arithmetic
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Segmentation fault (core dumped) due to fgets – I think
- What does “request for member ‘*******’ in something not a structure or union” mean?
- Unknown ending signal when using debugger gdb
- Valgrind: invalid read of size 4 -> sigsegv, works fine without valgrind and in visual studio
- error: too few arguments to function `printDay’ (C language)
- Is there a good Valgrind substitute for Windows?
- Difference between “move” and “li” in MIPS assembly language
- Undefined reference to main – collect2: ld returned 1 exit status
- How can one see content of stack with GDB?
- Is there a way to have printf() properly print out an array (of floats, say)?
- Proper way to empty a C-String
- malloc(): memory corruption
- How do you allow spaces to be entered using scanf?
- Where is the
header file on Linux? Why can’t I find ? - What is the difference between %g and %f in C?
- Why is the sizeof(int) == sizeof(long)?
- Structure padding and packing
- Allocating char array using malloc
- Difference between char *argv[] and char **argv for the second argument to main()
- Dynamic vs static array in c
- The difference between char * and char[] [duplicate]
- How to format strings using printf() to get equal length in the output
- “-bash: gcc: command not found” using cygwin when compiling c?
- In C, what exactly happens when you pass a NULL pointer to strcmp()?
- lseek/write suddenly returns -1 with errno = 9 (Bad file descriptor)
- Should I use printf(“\n”) or putchar(‘\n’) to print a newline in C?
- What do \t and \b do?
- error: struct has no member named X
- Constructor for structs in C
- write() to stdout and printf output not interleaved?
- Implicit function declarations in C
- Convert long long to string in C?
- Using pointer to char array, values in that array can be accessed?
- How can I create a dynamically sized array of structs?
- how to stop a loop arduino
- How to normalize a mantissa
- Level vs Edge Trigger Network Event Mechanisms
- variably modified array at file scope in C
- How to use shared memory with Linux in C
- When is it ok to use a global variable in C?