I want to finaly learn what's up with pointers and arrays, so i made up this program:
#include <stdio.h>
int main()
{
int cantidad_frases = 0;
printf("Cuantas frases quieres escribir?: ");
scanf("%d", &cantidad_frases);
char *frases[cantidad_frases];
for(unsigned i = 0; i < cantidad_frases; i++)
{
[B]for(; *frases[i]; frases[i]++)[/B]
{
*frases[i] = getchar();
}
}
printf("\nReproduciendo las frases:\n\n");
for(unsigned i = 0; i < cantidad_frases; i++)
{
printf("Frase %d:", i + 1);
[B]for(; *frases[i]; frases[i]++)[/B]
{
printf("%c", *frases[i]);
}
printf("\n");
}
return 0;
}
I had no errors nor warnings at all. But program crashes after entering the cantidad_frases value and hitting enter. The problem is in the 11th line.
I really didn't know how to "refer" each letter of the words/string stored in frases.
I hope i made my question clear enough so you can help me. Any advise or (please) any specific place where they explain the whole thing about pointers and arrays is more than welcome!