Guest User

Untitled

a guest
Dec 11th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include "pch.h"
  2. #include <iostream>
  3. #include <Windows.h>
  4. #include <thread>
  5. #include <string>
  6. #include <cstring>
  7.  
  8.  
  9. using namespace std;
  10.  
  11. // driver code
  12. int main()
  13. {
  14. // assigning value to string s
  15. string s = "geeksforgeeks";
  16.  
  17. int n = s.length();
  18.  
  19. // declaring character array
  20. char char_array[n + 1];
  21.  
  22. // copying the contents of the
  23. // string to char array
  24. strcpy(char_array, s.c_str());
  25.  
  26. for (int i = 0; i < n; i++)
  27. cout << char_array[i];
  28.  
  29. return 0;
  30. }
Add Comment
Please, Sign In to add comment