Hi,
The question is to input 3 names from user by char array and display names.
the 2 funcns r must:
a)getnames()
b)display array
As a selflearner,find this forum really helpful. Please look my code,and let me know where I am going wrong.
thanks in advance.Code:#include <iostream> using namespace std; const int rows =3; const int col=6; char getname(); void displayarray(const char [][6],int, int); int main() { char arrays[3][6]; getname(); displayarray(arrays,rows,col); return 0; } char getname() { char arraynames[3][6]; cout<<"enter 3 names"<<endl; for (int j=0;j<rows;j++) { for (int k=0;k<col;k++) { cin>>arraynames[j][k]; return arraynames[j][k]; } } } void displayarray(const char array[3][6],int r,int c) { for(int x=0;x<r;x++) { cout<<"name["<<x<<"]"; for(int i=0;i<c;i++) { cout<<getname[x][i]; } } }
Thanks



LinkBack URL
About LinkBacks


