Having trouble with some command line argurments, basically just trying to make a rectangle using command line argrumnents. Here's what I've got
#include <stdio.h> #include <stdlib.h> int main(int argc, char *argv[]){ int x; int y; int i; int j; x = atoi(argv[1]); y = atoi(argv[2]); fprintf(stderr, "Height & Width Needed\n", argv[0]); return 1; for(i = 0; i < x; i++) for(j = 0; j < y; j++) printf("*"); printf("\n"); return 0; } I know this is amateur hour but I'm just starting out. Added stderr for argv[0] statement, included atio, every time compile I just get my usage statement. I tried adding curly braces on my outer loop only, and then on the outer and inner loop, still just getting my stderr every time I run with commands.
int x = argv[1];-->x = atoi(argv[1]);(#include <stdlib.h>)ints, if anintis what's desired.atoiis one way. Other options:strtolandsscanf.for(i = 0; i <= x; i++)maybe -->for(i = 0; i < x; i++){ ... }