I wrote this simple code which scans in some numbers and words. However, I am confused because the char's always give me an error. What is wrong with it?
int main(int argc, char *argv[]) {
int val_pos, incr_val, max_val;
char *file_name;
char *new_name;
if (argc == 6) {
val_pos = atoi(argv[1]);
incr_val = atoi(argv[2]);
max_val = atoi(argv[3]);
file_name = argv[4];
new_name = argv[5];
} else {
printf("Command usage: %s <val_pos> <increment val> <max val> <file_name> <new name>\n", argv[0]);
printf("What is the position you want to change? Enter your number\n");
printf("X = 0 | Y = 1 | Z = 2\n");
scanf("%d", &val_pos);
printf("What is the increment value?\n");
scanf("%d", &incr_val);
printf("What is the max value/value we should terminate at?\n");
scanf("%d", &max_val);
printf("What is the pose file called?\n");
scanf("%s", &file_name);
printf("What should we call the newly generated files?\n");
scanf("%s", &new_name);
}
}
Aucun commentaire:
Enregistrer un commentaire