9511_workbook

solved exercises from algorithms & programming I (9511) prof. Cardozo
Index Commits Files Refs README
guia06/ex01.c (331B)
   1 #include <stdio.h>
   2 #include <stdlib.h>
   3 
   4 #define MSG_ERR_NO_ARG "Error: No arguments"
   5 
   6 #define STR_ARG_POS    1
   7 
   8 int main (int argc, char *argv[]) {
   9 
  10     if(argc == 1) {
  11         fprintf(stderr, "%s\n", MSG_ERR_NO_ARG);
  12         return 1;
  13     }
  14 
  15     size_t i = 0;
  16     while((*(argv + STR_ARG_POS))[++i])
  17         ;
  18 
  19     printf("%ld\n", i);
  20 
  21     return EXIT_SUCCESS;
  22 }