C-> Linux文件名构造问题 [英] C->Linux issue with filename construction

查看:64
本文介绍了C-> Linux文件名构造问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我有一些代码并且做了一些不寻常的事情:


这是我的代码:

展开 | 选择 | Wrap | 行号

解决方案

如何定义strFile ??


你是超出数组绑定?看起来它需要是至少18个字符的数组。



如何定义strFile ??


你是否超出数组绑定?看起来它需要是至少18个字符的数组。



char strFile [200];


从输入文件中读取gstrJobname。它也被指定为char gstrJobname [200];


我用这行读了它:

展开 | 选择 | Wrap | 行号

啊...我刚刚重读了fgets的描述,我错了,它包括了它读到的数组末尾的换行符。


我想我的后续问题是,如何从数据文件中读取一行数据到字符串(char数组),并且不用结束换行符?是否可以使用''获得'而不是fgets?甚至sprintf?


我一直在阅读这些,并且找不到环洞...


谢谢,

Sitko。


Hi,

I''ve some code and its doing some unusual stuff:

Here is my code:

Expand|Select|Wrap|Line Numbers

解决方案

How is strFile defined??

Are you overruning the array bound?? It looks like it needs to be an array of at least 18 chars.


How is strFile defined??

Are you overruning the array bound?? It looks like it needs to be an array of at least 18 chars.

char strFile[200];

gstrJobname is read in from an input file. it is also specified as char gstrJobname[200];

I read it in with this line:

Expand|Select|Wrap|Line Numbers


ah...I''ve just reread the description of fgets and I was mistaken, it includes the newline at the end of the array it reads to.

I guess my followup question would be, how do I read a line of data from a data file, into a string (char array), and leave off the ending newline? Is it posible to use ''gets'' instead of fgets? Or even sprintf?

I''ve been reading up on these, and can find no loop-hole...

Thanks,
Sitko.


这篇关于C-> Linux文件名构造问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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