Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<iostream>
- #include <string>
- using namespace std;
- void insertComma(char *s);
- int main()
- {
- char newS[100];
- cin.getline (newS,100);
- insertComma(newS);
- cout << newS;
- system("pause");
- return 0;
- }
- void insertComma(char *s) {
- int j = 0;
- int size = strlen(s);
- char newS[100];
- for (int i = 0; i < size; i++, j++) {
- newS[j] = s[i];
- if (isspace(s[i]) != 0) {
- j++;
- newS[j] = ',';
- }
- }
- newS[j] = '\0';
- strcpy_s(s, strlen(newS) + 1, newS);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement