新文件 [英] New File

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

问题描述

好吧......我还是编程新手,但我已经为互联网业务写了一个

的程序。有没有办法让我创建一个新的

文件夹,将文件夹变量的名称改为从文本中读取的名称

文档并在其中写入一个新的文本文档那个文件夹?所以

基本上,程序中的文件夹名称会根据从每个文本文件中收到的名称更改

。我希望所有

都有意义......我非常坚持这一点,希望有人可以帮助我。

-Thanks

Alright...I''m still new to programming, but I am already writing a
program for an internet business. Is there a way for me to make a new
folder with the name of the folder variable to a name read from a text
document and write a new text document inside of that folder? So
basically the name of the folder being made in the program would change
according to the name it recieved from each text file. I hope that all
made sense... Im pretty stuck with this and hope someone out there can
help me.
-Thanks

推荐答案

" EngineerGeek" <公顷*** @ onid.orst.edu>写道:

#好吧......我还是新编程,但我已经为互联网业务写了一个

#程序。有没有办法让我创建一个新的

#文件夹,将文件夹变量的名称改为从文本中读取的名称

#document并写一个新的文本文档在那个文件夹里面?所以

#基本上在程序中创建的文件夹的名称将根据从每个文本文件中收到的名称更改

#。我希望所有

#都有意义......我非常坚持这一点,并希望有人可以在那里

#帮助我。


通常可以在命令行界面输入任何命令,你可以使用system()函数执行
。例如,在Unix上,你可以做

类似

char * dir = ...;

char F [] =" mkdir -m 0755''%s''" ;;

char * f = malloc(strlen(dir)+ sizeof F);

sprintf(f,F, dir);

int ec = system(f);

free(f);


您的系统可能提供额外的接口超过ANSI C.对于

的例子,再次在Unix上,你可以做

char * dir = ...;

int ec = mkdir (dir,0755);


小心谨慎,您可以在代码中包含各种系统的接口。


-

SM Ryan http:// www.rawbw.com/~wyrmwif/

不要杀人。那是高调。
"EngineerGeek" <ha***@onid.orst.edu> wrote:
# Alright...I''m still new to programming, but I am already writing a
# program for an internet business. Is there a way for me to make a new
# folder with the name of the folder variable to a name read from a text
# document and write a new text document inside of that folder? So
# basically the name of the folder being made in the program would change
# according to the name it recieved from each text file. I hope that all
# made sense... Im pretty stuck with this and hope someone out there can
# help me.

Usually any command you can enter at a command line interface, you can
do with the system() function. For example, on Unix, you can do
something like
char *dir = ... ;
char F[] = "mkdir -m 0755 ''%s''";
char *f = malloc(strlen(dir)+sizeof F);
sprintf(f,F,dir);
int ec = system(f);
free(f);

Your system probably provides additional interfaces beyond ANSI C. For
example, again on Unix, you can do
char *dir = ... ;
int ec = mkdir(dir,0755);

With due care you can include the interfaces for a variety systems in
your code.

--
SM Ryan http://www.rawbw.com/~wyrmwif/
Quit killing people. That''s high profile.


EngineerGeek写道:
EngineerGeek wrote:
好吧......我还是编程新手,但我已经为互联网业务编写一个
程序。有没有办法让我创建一个新的
文件夹,其中文件夹变量的名称是从文本
文档中读取的名称,并在该文件夹中写入一个新的文本文档?所以
基本上,程序中的文件夹名称会根据从每个文本文件中收到的名称而改变。我希望所有
都有意义......我非常坚持这一点,希望有人可以帮助我。
Alright...I''m still new to programming, but I am already writing a
program for an internet business. Is there a way for me to make a new
folder with the name of the folder variable to a name read from a text
document and write a new text document inside of that folder? So
basically the name of the folder being made in the program would change
according to the name it recieved from each text file. I hope that all
made sense... Im pretty stuck with this and hope someone out there can
help me.




C确实解决了文件系统,因为它们完全是特定于操作系统的。在

情况下,目录(或婴儿谈话中的文件夹)已存在

,文件的实际名称是由
目录,一个分隔符,然后是本地目录。文件名。这样的

名称可以使用标准C语言轻松构建,并用于打开新文件
。但是,如果你需要创建一个新目录,那么你需要使用你的操作系统提供的功能,毕竟,这是特定于操作系统的b $ b。如果您的文档不充分(或者,更有可能,您不知道如何使用它),请在新闻组中询问您的操作系统。这些细节

不是C语言的一部分。



C does address file systems, since they are completely OS-specific. In
situations where the directory (or "folder" in baby-talk) exists
already, the actual name of the file is built of a path to the
directory, a separator, and then the "local" name of the file. Such
names can be built easily with standard C funtionality and used to open
a new file. If, however, you need to create a new directory, you will
need to use the functionality your OS provides for what is, after all,
OS-specific. If your documentation is inadequate (or, more likely, you
don''t know how to use it), ask in a newsgroup for your OS. Such details
are not part of the C language.


Martin Ambuhl写道:
Martin Ambuhl wrote:
C确实解决了文件系统的问题,因为它们完全是特定于操作系统的。
C does address file systems, since they are completely OS-specific.




应该是C确实*不*地址文件系统,因为它们是

完全针对特定操作系统。



That should have been "C does *not* address file systems, since they are
completely OS-specific."


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

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