0
can any one help me why after entering numbers and names why i get wrong answer? i expect after entering marks and names the com
#include<iostream> #include<cstring> class list{ private: char names[2][10]; int y[2]; public: void setnames(char names[2][10]); void setmarks(int x[2]); void display(){ for(int j=0;j<2;j++) std::cout<<names[j]<<" "<<y[j]<<std::endl; } }; void list::setnames(char b[2][10]){ for(int i=0;i<2;i++) for(int p=0;p<10;p++) names[i][p]=b[i][p];} void list::setmarks(int x[2]){ for(int i=0;i<2;i++) y[i]=x[i]; } int main() { std::cout<<"enter your names"<<std::endl; char p[2][10]; int m[2]; for(int i=0;i<2;i++) std::cin>>m[i]; for(int n=0;n<2;n++) std::cin.getline(p[n],10); list l; l.setmarks(m); l.setnames(p); l.display(); }
2 Respuestas
+ 1
i think the problem relates to differences of char and char array but i dont know what happens exactly.
+ 1
Save code in playground and share link here so that it helps to identify problem easily..
What is your input and expected output there.. Mention details pls..
edit:
This may help you, to share links 👇
https://www.sololearn.com/post/75089/?ref=app