C - Write program to output random string


write a program that will output a randomly chosen string from a set of at least five string.


#include <stdio.h>
#include <time.h>
#include <stdlib.h>
#define MAX_LEN    50         // Maximum thought string length

int main(void)
  char thoughts[][MAX_LEN] = {"test 1",
                              "test 2",
                              "test 3",
                              "test 4",
                              "test 5",
                              "test 6"};

  srand((unsigned int)time(NULL));

  printf("Today's thought is:\n%s\n", thoughts[rand()%(sizeof(thoughts)/MAX_LEN)]);
  return 0;//from   ww  w . j  a v  a2  s . c om