Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void chchar(char* ch){
- ch = "asfafgag";
- }
- char* array = "abc";
- chchar(array);
- cout << array;
- #include <iostream>
- #include <cstring>
- #include <stdlib.h>
- using namespace std;
- void chchar(char** str)
- {
- strcpy(*str, "String data from `chchar`");
- }
- int main(int argc, char** argv)
- {
- char* data = static_cast<char*>(malloc(sizeof(100)));
- strcpy(data, "Blablbla");
- printf("Data before call `chchar`: %sn", data);
- chchar(&data);
- printf("Data before call `chchar`: %sn", data);
- free(data);
- system("pause");
- }
- #include <iostream>
- #include <cstring>
- #include <stdlib.h>
- using namespace std;
- void chchar(char*& str)
- {
- strcpy(str, "String data from `chchar`");
- }
- int main(int argc, char** argv)
- {
- char* data = static_cast<char*>(malloc(sizeof(100)));
- strcpy(data, "Blablbla");
- printf("Data before call `chchar`: %sn", data);
- chchar(data);
- printf("Data before call `chchar`: %sn", data);
- free(data);
- system("pause");
- }
Add Comment
Please, Sign In to add comment