#include <string.h>
#include <stdlib.h>
int main(int argc, char *argv[]) {
char *operation;
operation = argv[1];
int num1 = atoi(argv[2]);
int num2 = atoi(argv[3]);
if(strcmp(operation, "+") == 0) {
printf("%d", num1 + num2);
}
else if(strcmp(operation, "-") == 0) {
printf("%d", num1 - num2);
}
else if(strcmp(operation, "*") == 0) {
printf("%d", num1 * num2);
}
else if(strcmp(operation, "/") == 0) {
printf("%d", num1 / num2);
}
return 0;
} ```
Umm, guys, I want to ask why my code is not working when I'm typing * in the command line and when changing the string name it's working properly
#Command line utility
13 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
"changing the string name" ?
I mean like changing the '*' to multiple or something else
try running your program as myprogram '*' 5 6 instead of myprogram * 5 6
I had to do that on my system because my shell was interpreting the * as a glob command instead of text to send to the program
yeah
Try double quotes
Might be a Windows thing