At 12:06 PM 04/06/2013, you wrote: >Circuit Cellar have a code challenge that asks contestants to >determine the error in the code below. > > >I like a challenge but I am not too familiar with c but it seems that >there are several areas that look odd in the code. The contest seems >to imply that there is only one error so I suspect I am wrong. > > >I get ... > >Line 5. Declares a variable that is never used (not sure if that is an >error per se) Nope. Maybe a warning. >Line 8. Should be i++ not ++i This is a pre-increment rather than post-increment, so you start with 1 rather than 0. Not wrong. If you wanted to use i++ you'd have to start with i =3D 1. >Line 9. '%s' not sure what effect the single quotes have but they look wro= ng The characters are just reproduced in the printed string. Not wrong. >Line 9. *argv[i] should be argv[i] Yup. that's what they are looking for. argv[] is an array of pointers to char. >Line 10.1. perhaps a "return" in the function main since it is=20 >declared as int. Not an error. C89 says it will return an unspecified value. C99 says it will return 0, but it will return. May not generate a warning. >1. #include >2. >3. int main (int argc, char *argv[])4. { >5. char ch; >6. int i; >7. >8. for (i =3D 0; i < argc; ++i) { >9. printf ("Argument #%d: '%s'\n", i, *argv[i]); >10. }11. } > > >Justin >-- >http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive >View/change your membership options at >http://mailman.mit.edu/mailman/listinfo/piclist --=20 http://www.piclist.com/techref/piclist PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .