To specify my question, am I referencing the the commands in int main directly when using the function, or am I copying them, and then referencing those copies using the function? I'm having trouble understanding pointers, and strings in C.
Also, if I'm doing this error checking in a really stupid way, and you know how it could be better, I'd love to be enlightened. I'm coming from Python, and am still learning C to a large extent. My goal currently is to write a very minimal compiler that will do simple addition.
#include <stdio.h>
int CompilationErrorChecking(int argc, char *argv[]){
// Check initialy if for at least one argument attatched to Iwa
if (argc < 2 && argc == 1){
printf("Error: No arguments found");
// If the arguments are correct: Iwa_Compiler <FileName>
// Execute, and say the command back to them
} else if (argc <= 2){
printf("%s %s\n", argv[0], argv[1]);
// If there are more than 2 arguments, spit error
} else {
printf("Erorr: Too many arguments");
}
return 0;
}
int main(int argc, char *argv[]) {
CompilationErrorChecking(argc, argv);
return 0;
}