fopen操纵(在C中) [英] fopen manipulation (in C)

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

问题描述

请回答C中的答案。


好​​吧让我们说我们有一个结构:

Please respond with answers in C.

Alright so lets say we have a structure:

展开 | 选择 | Wrap | 行号

推荐答案

您的代码无法运行。 INFO不是变量。这是一个姓名。看看typedef正在做什么。无论如何,您正在寻找的概念是字符串连接。在C中有一个功能。它是strcat。或strncat。
Your code won?t work. INFO is not a variable. It?s a typename. Look at what that typedef is doing. In any case, the concept you are looking for is string concatenation. There?s a function for that in C. It?s strcat. Or strncat.


最后一行是psuedo代码,因为评论说,当然它不起作用


我会问同样的问题另一种方式。


我需要打开一个依赖于INFO.Descript值的文件


如果Descript是aa0001我需要它打开文件aa0001.txt

如果Descript是ab1234我需要它打开文件ab1234.txt

等..
the last line is psuedo code as the comment says, of course it doesnt work

I''ll ask the same question in another way.

I need to open a file which is dependent on the value of INFO.Descript

if Descript is aa0001 i need it to open file aa0001.txt
if Descript is ab1234 i need it to open file ab1234.txt
etc..


我会再解释一下。

I?ll explain again.


最后一行是psuedo代码,评论说,当然它不起作用
the last line is psuedo code as the comment says, of course it doesnt work



当然可以,但我还没在谈论最后一行。当您执行类似INFO.Descript的操作时,您将INFO视为变量。这不是变数。 INFO是您创建的新类型(结构)的名称。你现在看到代码有问题吗?

Sure, but I wasn?t talking about the last line. When you do something like INFO.Descript, you treat INFO as a variable. It?s not a variable. INFO is the name of a new type you created (the struct). Do you see a problem with your code now?


如果Descript是aa0001我需要它打开文件aa0001.txt

如果Descript是ab1234我需要它打开文件ab1234.txt

等..
if Descript is aa0001 i need it to open file aa0001.txt
if Descript is ab1234 i need it to open file ab1234.txt
etc..



是的。你在做什么是连接?.txt?一些字符串。字符串连接。

Yes. What you are doing is concatenating ?.txt? to some string. String concatenation.


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

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