Run Code
|
API
|
Code Wall
|
Users
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
strcpy
#include <iostream> #include <cstdio> #include <cstring> using namespace std; class Test{ public: char* name; Test():name(new char[10]){} void set(char* value){ /*int i=0; while(*value != 0){ *(name+i) = *(value++); ++i; } *(name+i) = 0;*/ strcpy(name,value); } }; 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(); data[i]->set(in); } for(int i=0;i<3;++i){ cout<< data[i]->name<<endl;//output: A B C } return 0; }
run
|
edit
|
history
|
help
0
Please
log in
to post a comment.
StrSubCpyFind
csv parser
t>0
odws
Lowest common ancestor
simple use of templete
stl_sizeof.cc
Straight Max-Min Divide and Conquer
ExceptionHandling4
Gauss 4x4
Please log in to post a comment.