我正在尝试在C ++中使用# .bashrc
# User specific aliases and functions
. .alias
alias ducks='du -cks * | sort -rn | head -15'
# Source global definitions
if [ -f /etc/bashrc ]; then
. /etc/bashrc
fi
PATH=$PATH:/home/montypython/bin:/usr/hla:$PATH
export PATH
hlalib=/usr/hla/hlalib
export hlalib
hlainc=/usr/hla/include
export hlainc
if [ -f ~/.alias ]; then
. ~/.alias
fi
从字符串中删除空格
但是,我只得到字符串的第一部分。
这是我的代码-
strtok()
对于输入-#include<bits/stdc++.h>
#include <iostream>
using namespace std;
void removeSpaces(string str)
{
int n = str.length();
int i=0;
char c[n+1];
strcpy(c,str.c_str());
char *token=strtok(c," ");
while(token!=NULL){
cout<<token;
token=strtok(NULL," ");
}
}
int main(int argc, char const *argv[])
{
string str;
cin>>str;
removeSpaces(str);
}
输出为Geeks for ge k s
但是,我需要将输出作为Geeks