I am using this code to print arguments that are less or equal to 100. The problem happens when i try to compile, it always give me the error Segmentation Fault althought I do not know why this is happening. Can anyone help me to understand what is happening?
#include <stdio.h>
#include <stdlib.h>
int main(int argc, char **argv)
{
printf("# args: %d\n", argc);
printf("l1 %s\n", argv[2]);
printf("l2 %d\n", atoi(argv[3]));
int argumentos = argc;
for (int i = 0; i < argumentos; i++)
{
if (atoi(argv[i + 1]) >= 100)
{
printf("%d", atoi(argv[i + 1]));
}
else
{
printf("vai dar não!");
}
}
return EXIT_SUCCESS;
};