C中的空格 [英] Spaces in C

查看:49
本文介绍了C中的空格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我这里有一小块程序


基本上它的作用是,它复制可变宽度的字符串。

基础是直到它找到逗号,。输入是一个CSV /逗号分隔

文件。


现在的问题是它没有计算Spaces。例如,阅读下面的

以下程序是可以的:


123,你好,3422C

3994,Hii ,39948D


结果:很好,有效;


但如果我有如下字符串的话;

123,你好,你好,99399 C


结果:嗨之后无法阅读因为空间,你能否建议将任何

代码更改为以下存根?


谢谢

J

--------------------------

int j = 0;

char c;

c = ptr [0];

ibic [0] = c;

while(c!='','' )

{

++ j;

c = ptr [j];

ibic [j] = c ;

}

ibic [j] =''\ 0'';

返回0;

-------------------------

Hi,

I have a little piece of program here

Basically what it does is, it copies the strings of variable widths. The
basis is until it finds a comma ",". The input is a CSV/Comma Separated
file.

Now the problem is that it is not counting Spaces. For example to read the
following line with the below Program is OK:

123, Hello, 3422C
3994,Hii,39948D

Result: Fine, works;

But if I have the strings like the below;
123, Hi How are you,99399 C

Result: Fails to read after "Hi" because of the space, can you suggest any
code changes to below stub?

Thanks
J
--------------------------
int j = 0;
char c;
c = ptr[0];
ibic[0] = c;
while(c != '','')
{
++j;
c = ptr[j];
ibic[j] = c;
}
ibic[j] = ''\0'';
return 0;
-------------------------

推荐答案



Joriveek <无**** @ please.com>在消息中写道

news:ds ********** @ reader01.news.esat.net ...

"Joriveek" <no****@please.com> wrote in message
news:ds**********@reader01.news.esat.net...

<我这里有一小段程序

基本上它是做什么的,它复制了可变宽度的字符串。
基础是直到它找到逗号,。输入是一个CSV /逗号分隔的文件。

现在的问题是它没有计算Spaces。例如用以下内容阅读
以下程序是可以的:

123,你好,3422C
3994,Hii,39948D

结果:很好,有效;

但如果我有如下的字符串;
123,你好,你好,99399 C

结果:无法阅读后 ;您好"因为空间,你能否建议将任何代码更改到下面的存根?

谢谢
J
------------- -------------
int j = 0;
char c;
c = ptr [0];
ibic [0] = c ;
while(c!='','')
{
++ j;
c = ptr [j];
ibic [j] = c ;
}
ibic [j] =''\ 0'';
返回0;
---------------- ---------
Hi,

I have a little piece of program here

Basically what it does is, it copies the strings of variable widths. The
basis is until it finds a comma ",". The input is a CSV/Comma Separated
file.

Now the problem is that it is not counting Spaces. For example to read the
following line with the below Program is OK:

123, Hello, 3422C
3994,Hii,39948D

Result: Fine, works;

But if I have the strings like the below;
123, Hi How are you,99399 C

Result: Fails to read after "Hi" because of the space, can you suggest any
code changes to below stub?

Thanks
J
--------------------------
int j = 0;
char c;
c = ptr[0];
ibic[0] = c;
while(c != '','')
{
++j;
c = ptr[j];
ibic[j] = c;
}
ibic[j] = ''\0'';
return 0;
-------------------------




你确定问题出在那个存根中,而不是在例程中读取

和填写''ptr''?

Rod Pemberton



Are you sure the problem is in that stub and not in the routine that reads
and fills ''ptr''?

Rod Pemberton





Joriveek写道在02/13/06 11:00,:


Joriveek wrote On 02/13/06 11:00,:


我这里有一小段程序
Hi,

I have a little piece of program here




请将整个内容发布 - 如果它很长,请将其减少到

必需品,但是发布一个完整的可编辑的
程序。当你生病时,你是否将整个

的身体带到医生处或只是送一绺头发?


-
< a href =mailto:Er ********* @ sun.com> Er ********* @ sun.com



Please post the entire thing -- reduce it to its
essentials if it''s long, but post a complete compilable
program. When you are sick, do you take your entire
body to the doctor or just send a lock of your hair?

--
Er*********@sun.com


抱歉,这是用于读取CSV文件;

如果有空格,它不起作用,只读它是否是连续的

string。

" Rod Pemberton" <做********* @ sorry.bitbucket.cmm>在消息中写道

news:43 ******** @ news.bea.com ...
sorry, it is for reading a CSV file;
if there are spaces, it is not working, just reading if it is a continuous
string.
"Rod Pemberton" <do*********@sorry.bitbucket.cmm> wrote in message
news:43********@news.bea.com...

Joriveek <无**** @ please.com>在消息中写道
新闻:ds ********** @ reader01.news.esat.net ...

"Joriveek" <no****@please.com> wrote in message
news:ds**********@reader01.news.esat.net...


我这里有一小块程序

基本上它做的是,它复制可变宽度的字符串。
基础是直到它找到逗号,。输入是一个CSV /逗号分隔的文件。

现在的问题是它没有计算Spaces。例如阅读

下面的程序如下程序可以:

123,你好,3422C
3994,Hii,39948D

但如果我有下面的字符串;
123,你好,你好,99399 C

结果:失败在嗨之后阅读因为空间,你能否建议将任何代码更改到下面的存根?

谢谢
J
--------- -----------------
int j = 0;
char c;
c = ptr [0];
ibic [ 0] = c;
while(c!='','')
{
++ j;
c = ptr [j];
ibic [ j] = c;
}
ibic [j] =''\ 0'';
返回0;
------------ -------------
Hi,

I have a little piece of program here

Basically what it does is, it copies the strings of variable widths. The
basis is until it finds a comma ",". The input is a CSV/Comma Separated
file.

Now the problem is that it is not counting Spaces. For example to read
the
following line with the below Program is OK:

123, Hello, 3422C
3994,Hii,39948D

Result: Fine, works;

But if I have the strings like the below;
123, Hi How are you,99399 C

Result: Fails to read after "Hi" because of the space, can you suggest
any
code changes to below stub?

Thanks
J
--------------------------
int j = 0;
char c;
c = ptr[0];
ibic[0] = c;
while(c != '','')
{
++j;
c = ptr[j];
ibic[j] = c;
}
ibic[j] = ''\0'';
return 0;
-------------------------



你确定问题出在那个存根中,而不是在例程中读取和填充''ptr ''?

Rod Pemberton



Are you sure the problem is in that stub and not in the routine that reads
and fills ''ptr''?

Rod Pemberton



这篇关于C中的空格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆