0

I worked with C about 3 years ago and haven't used it at all since. So it's all a bit fuzzy and I don't remember anything beyond the basics

I'm currently attempting to writing a program in C and am currently trying to find a way to shuffle this array

char Colors[][7] = {"Red", "Purple", "Yellow", "White", "Blue", "Green"};

and then pull the colors and store them at

char color1[7];
char color2[7];
char color3[7];
char color4[7];
char color5[7];
char color6[7];

on a similar note how would I have it check to see

if char color1[7] = Red

and if so have it choose between two possible values in this array

char red[][22] = {"first", "second"};
  • 2
    Copy strings: `strcpy()`; compare strings: `strcmp()` – timrau Oct 27 '14 at 02:17
  • 3
    What is your question: how to compare strings, how to shuffle arrays, how to do everything? Your current code is nothing but a few definitions. – Yu Hao Oct 27 '14 at 02:19
  • 2
    If you intend to rearrange the strings, it may be better to use a 1D array of `char *` rather than a 2D array of `char`. That would let you shuffle by moving the pointers around in the array instead of copying the strings. – Dmitri Oct 27 '14 at 02:28
  • Thank you Timrau for your answer and Dimitri for your suggestion. you guys really helped me out. – AnonUser Oct 27 '14 at 22:31

0 Answers0