When I run my CLI program on my iphone i get a Segment fault: 11 error. I dunno what to do, I’m a noob at C.
int main (int argc, const char * argv[])
{
if (argc > 1 && (!strcmp(argv[1],"--help") || !strcmp(argv[1],"-h"))) {
printf("#### redhai 1.2 ####\n");
printf("-j Jailbreak\n");
printf("-i Device info\n");
printf("-a About\n");
printf("*END OF HELP*\n");
printf("####################\n");
return 0;
}else if (!strcmp(argv[1],"-j")) {
printf("Coding the jailbreak portion!\n");
return 0;
}
return 0;
}
You are accessing
argv[1]without first checking if it exists. You need to first check ifargc > 1.