bogdanNiculeasa

Inversa nume prenume si folosire initiala v2

Dec 7th, 2022
1,364
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.33 KB | None | 0 0
  1. #include <iostream>
  2. #include <string.h>
  3.  
  4. using namespace std;
  5.  
  6.  
  7.  
  8. int main() {
  9.     char s[21];
  10.     char result[21];
  11.     cin.getline(s, 21);
  12.  
  13.     // s contine Popescu      Vasile
  14.     strncpy(result, strrchr(s, ' ')+1, 1);
  15.     result[1] = '\0';
  16.     strcat(result, ". ");
  17.     strcat(result, strtok(s, " "));
  18.  
  19.     cout << result;
  20.  
  21.     return 0;
  22. }
  23.  
Advertisement
Add Comment
Please, Sign In to add comment