Kimossab

Messing with strings...

Oct 25th, 2014
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.50 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdio.h>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. char Buffer[240] = "Hello World!";
  8. #define Oops "This program was made by %s. Not emokid at all. Hell no. I %s did this!"
  9.  
  10. void main()
  11. {
  12.     char Name [124];
  13.     cout << Buffer;
  14.     cout << endl << "Please insert you name: ";
  15.     cin >> Name;
  16.  
  17.     char *pch;
  18.     pch = strstr(Buffer,"World");
  19.     strncpy(pch,Name,sizeof(Name)-1);
  20.     cout << endl << Buffer;
  21.  
  22.     sprintf(Buffer, Oops, Name,Name);
  23.     cout << endl << Buffer << endl;
  24. }
Advertisement
Add Comment
Please, Sign In to add comment