fork download
  1. #include <stdio.h>
  2.  
  3. #define NUM_OF_NAMES 20
  4. #define NAME_SIZE 15
  5.  
  6. int readNames(int);
  7. int readName(int);
  8. int sortNames();
  9. int printNames();
  10.  
  11. char* names[NUM_OF_NAMES];
  12. char nameHolder[NAME_SIZE];
  13.  
  14. int main () {
  15. readNames(NUM_OF_NAMES);
  16. printf("\n");
  17. printNames();
  18. return 0;
  19. }
  20.  
  21. int readNames(int qty) {
  22. for ( int i = 0; i < qty; i++ ) {
  23. readName(i);
  24. printf("%s \n", names[i]);
  25. }
  26. return 0;
  27. }
  28.  
  29. int readName() {
  30. char c;
  31. for ( int i = 0; i < NAME_SIZE; i++ )
  32. nameHolder[i] = '\0';
  33. for ( int i = 0; i < NAME_SIZE; i++ ) {
  34. c = getchar();
  35. if ( (c == '\"') || (c == 32) )
  36. c = getchar();
  37. if (c == ','){
  38. names[target] = nameHolder;
  39. return 0;
  40. }
  41. nameHolder[i] = c;
  42. }
  43. names[target] = nameHolder;
  44. return 0;
  45. }
  46.  
  47. int sortNames() {
  48. return 0;
  49. }
  50.  
  51. int printNames() {
  52. for ( int i = 0; i < NUM_OF_NAMES; i++ ) {
  53. printf("%s \n", names[i]);
  54. }
  55. return 0;
  56. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.c: In function ‘readName’:
prog.c:29:1: error: number of arguments doesn’t match prototype
 int readName() {
 ^~~
prog.c:7:5: error: prototype declaration
 int readName(int);
     ^~~~~~~~
prog.c:38:19: error: ‘target’ undeclared (first use in this function)
             names[target] = nameHolder;
                   ^~~~~~
prog.c:38:19: note: each undeclared identifier is reported only once for each function it appears in
stdout
Standard output is empty