Hello all,
I recently was doing an assignment for my c class and I ran into a small problem.
I haven't started much on the rest of the program, and I am currently decoding the command line arguments
It seems whenever I use system("pause"); at the end of my program (before return 0;) it crash and I have no idea why.
It has to do with the concat's I'm using. Commenting out those stops the crashes.
Here is my code (I commented most of it out):
any idea why its not working?Code:#include <stdlib.h> #include <stdio.h> #include <stdbool.h> // I like my booleans #include <string.h> #include "lc3.h" int main(int argc, char* argv[]) { int CLA = 2; // override found command line arguments // (setting this as 8 or 0 also crashes the program) if((CLA & 2) == 2) //if -b { if(strstr(argv[argc-1],".bin")==null) // if .bin is not in the filename { strcat(argv[argc-1],".bin"); // concat .bin to the filename } } if((CLA & 8) == 8) //if -m { if(strstr(argv[argc-1],".mco")==null) // if .mco is not in the filename { strcat(argv[argc-1],".mco"); // concat .mco to the filename } } if((CLA & 10) == 0) //if not -b or -m { if(strstr(argv[argc-1],".hex")==null) // if .hex is not in the filename { strcat(argv[argc-1],".hex"); // concat .hex to the filename } } printf("\n\n%s",argv[argc-1]); printf("\n\n"); system("pause"); // if I remove this, my program ends succesfully return 0; }
Thanks,
Kairos



LinkBack URL
About LinkBacks



