![]() You can simply rely on the atoi() std function to do everything you need in this case. I see what you were setting up to do here with this loop but it is unnecessary. That's semantic only but helps me identify what that value should be. Then I created a char* variable called key to look at the same value that lies at argv. I only did this to show a more typical definition. * I commented out your original code and have replaced it as such */įirst I changed the definition of main from using type string to char*, this is purely semantic as far as I am concerned. If you don't use the string lib then the definition of main is:įor (int i = 0, n = strlen(argv) i n i++) Maybe this is a helpful lib, but char* is just the same. * There is no reason to use the string lib IMO when only using it for argv. Personally I recommend not using it, but its your call. * I'm not really a fan of the cs50.h lib. Its up to you how you intend the end result to be/look. One of which you may want to keep around, but the others maybe not.
0 Comments
Leave a Reply.AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |