Printing the set of all words in an alphabet in C -


i'm trying code program prints set of words in alphabet. test me used strings , pointers in c. have settled on recursive solution, seem having trouble using pointers in strcat. suggestions why i'm getting segfaults here?

    #include <stdio.h>     #include <stdlib.h>     #include <string.h>      #define dim 26      void print (char *);      char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',                      'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};     char word[26];       int main(void) {         *word = '\0';         print(word);         return exit_success;     }      void print (char *word){         (int = 0; < dim; ++i){             strcat(word, alphabet[i]);             printf("%c\n", word);             print(*word);         }     } 

  • the second argument of strcat string. have send null-terminated array of char.
  • the %c format of printf indicates int, word pointer char.

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

CSS3 Transition to highlight new elements created in JQuery -