I have a problem with the third element from notas:
When I run this code this appears :
I can't find why the notas[2] element couldn't be assigned to the corresponding note (it says that it has a null value), and when I press a key to exit the program, it displays:
Where's the problem?
(I don't know if it this can be helpful but I'm using Borland Turbo C++ 3.0)
Thank you very much.
Code:
#include <iostream.h>
#include <conio.h>
struct nota_musical
{
char *nota;
};
int main()
{
clrscr();
// Array of pointers
nota_musical *notas[7];
char *notmusic[7] = {"do", "re", "mi", "fa", "so", "la", "si"};
for (int i = 0; i < 7; i++)
notas[i] -> nota = notmusic[i];
for (int j = 0; j < 7; j++)
cout << "notas[" << j << "] -> nota " << notas[j] ->
nota << endl;
getche();
return 0;
}
Code:
notas[0] -> nota do
notas[1] -> nota re
notas[2] -> nota
notas[3] -> nota fa
notas[4] -> nota so
notas[5] -> nota la
notas[6] -> nota si
Code:
" Abnormal program termination
Null pointer assignment "
(I don't know if it this can be helpful but I'm using Borland Turbo C++ 3.0)
Thank you very much.