Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Blog
char array in class
#include <cstdio> using namespace std; class Test{ public: char name[10]; Test(char* n){ int i=0; while(*n != 0) name[i++] = *(n++); } }; int main(){ char in[10]; Test* data[3]; for(int i=0;i<3;++i){ scanf("%s",&in);//input: A B C data[i] = new Test(&in[0]); } for(int i=0;i<3;++i){ printf("%s ",data[i]->name);//output: A B C } return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
Policy based smart pointer
variadic template
Common elements in 3 sorted vectors with extra space
List Add v3
bin search
ssss
Sorting sort function stl in c++
c2p_update
javascript style arrays in c++
generating all valid parenthesis
stackse - search stackoverflow differently
Please log in to post a comment.