I used windows ansi C compilers for a while since excode didn't have some of the functions that my teachers at school use. But now that we are doing C++ i decided to move to xcode.
Now the second program i wrote (one involving structures). Has an error that i donot recognise. Can anybody help me with this?
Error:
expected initializer before "alumno"
'alumno' was not declared in this scope
SOURCE CODE:
#include<iostream.h>
struct datos{
int ide, edad;
char nombre[30];
float promedio;
}
datos alumno={0,0,"",0.0};
//funciones
void entrar();
void mostrar();
int main(){
entrar();
mostrar();
return 0;
}
void entrar(){
cout<<"ide";
cin>> alumno.ide;
cout<< "nombre";
cin>>alumno.nombre;
}
void mostrar(){
cout<<alumno.ide<<"\n";
cout<<alumno.nombre;
}
thanks!
Now the second program i wrote (one involving structures). Has an error that i donot recognise. Can anybody help me with this?
Error:
expected initializer before "alumno"
'alumno' was not declared in this scope
SOURCE CODE:
#include<iostream.h>
struct datos{
int ide, edad;
char nombre[30];
float promedio;
}
datos alumno={0,0,"",0.0};
//funciones
void entrar();
void mostrar();
int main(){
entrar();
mostrar();
return 0;
}
void entrar(){
cout<<"ide";
cin>> alumno.ide;
cout<< "nombre";
cin>>alumno.nombre;
}
void mostrar(){
cout<<alumno.ide<<"\n";
cout<<alumno.nombre;
}
thanks!