Quantcast
Channel: In C how do I dynamically add command line arguments to a string array? - Stack Overflow
Browsing all 5 articles
Browse latest View live

Answer by ajay for In C how do I dynamically add command line arguments to a...

If you define your main with the signature asint main(int argc, char *argv[]);then, here argv is an array of pointers to strings passed as command line arguments. Quoting the C99 standard section...

View Article



Answer by Floris for In C how do I dynamically add command line arguments to...

See if the following helps:#include <stdio.h>#include <string.h>#include <stdlib.h>int main(int argc, char* argv[]) { char** myStrings; int ii; myStrings = malloc(argc * sizeof...

View Article

Answer by Olaf Dietsche for In C how do I dynamically add command line...

This depends on what you want to achieve.You can use argv as it is. argv is already an array of string pointers.You can use a fixed size array, e.g. char argv_copy[7][256]. This means, you can use an...

View Article

Answer by nullptr for In C how do I dynamically add command line arguments to...

argv is a 'string array' itself: it is an array of char*.You can simply duplicate it (allocating memory for each element). Using a 2D array of char (as you suggest) for strings might be not a very...

View Article

In C how do I dynamically add command line arguments to a string array?

At the moment the only way I can see it is by cycling through the argv argument list, getting the largest of the input strings and creating a new dynamic array with this largest size dictating the...

View Article

Browsing all 5 articles
Browse latest View live


Latest Images