I want to store each of the 5 book names in the array and print them out. But what am I doing wrong here ? The output prints out the last entry 5 times.
#include <stdio.h>
int main(int argc, const char * argv[])
{
char * books[5];
char currentBook[1024];
for(int i = 0; i < 5; i++)
{
printf("Enter book:\n");
gets(currentBook);
books[i] = currentBook;
}
for(int i = 0; i <5; i ++)
{
printf("Book #%d: %s\n", i, books[i]);
}
}