ubuntu安装xcode包_求高人ubuntu下安装xcode

字符数组变量nspace大小等于10的时候正常,但是等于1或2的时候就不正常了 。

测试输入(以下的制表符可能变成空格了):

代码:

meet   you   how   are   you   i   am   fine   thank   you   and   you?   very   well   what   meet   you   how   are   you   iam   fine   thank   you   and   you?   very   well   what   meet   you   how   are   you   i   am   fine   thank   you   and   you?   very   well   what   meet   you   how   are   you   i   am   fine   thank   you   and   you?   very   well   what   meet   you   how   are   you   i   am   fine   thank   you   and   you?   very   well   what   meet   you   how   are   you   i   am   fine   thank   you   and   you?   very   well

这段代码用来分割输入的行,并把制表符换成多个空格,5列后分行

代码:

#include

#define MAXLINE 10000

int main(){

char input[MAXLINE];

getline1(input,MAXLINE);

int i,l;

int n=5;

int currenttab=0;

char nspace[2]={' ',' '};

char s[10];

int k=0;

for(i=0;i

//printf("%c\n",input[i]);

if(input[i]!='\t'){

s[k]=input[i];

k++;

}

else{

s[k]='\0';

printf("%10s",s);

k=0;

currenttab++;

printf("%s",nspace);

if((currenttab%n)==0)

printf("\n");

}

}

printf("\n");

}

int getline1(char s[],int lim){

int i;

char c;

for(i=0;i

s[i]=c;

}

if(c=='\n'){

s[i]=c;

i++;

}

s[i]='\0';

return i;

}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值