I'm trying to make a C console program that accepts arguments. Right now I'm checking that all the parameters are read correctly.
I use codeblocks.
Here is my code:
Code:
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char *argv[])
{
char i = 1;
printf("Hello world!\n");//Keeping this in to verify that at least something worked.
while(argv[i] != NULL)
{
printf(argv[i] + '\n');
i ++;
}
return 0;
}
With no parameters, it prints normally.
https://i.imgur.com/AUw6GXi.png
With a parameter of -b or --b, it does this:
https://i.imgur.com/WTamUqI.png
With parameters of --b and --4, it does this:
https://i.imgur.com/b6aA49u.png
I assume this has something to do with it accessing system/global variables? What is going on here? How do get it to read the variables passed to it as an 2d array of chars, which I can use in my program? I don't need or want to access system variables, I just need it to read things passed to it as strings which I can then operate on in my program.