有四道C语言的基础有关问题看看大家可以做上几道?
有四道C语言的基础问题看看大家可以做上几道??
1. Write a program in C to read in a text file and then print it out in reverse order. Pass the input file name to your program as a command line argument. The format of the input/output is up to you.
2. Write a program in C that appends information to an existing file. After you have finished processing your input data, proofread the information entered and make necessary changes needed if any typographical error is detected. To make it uniform, show and update contents one line at a time. You may use temporary file(s) in solving this problem, even though it is not encouraged.
3. Write a program in C to print out the status of an entry in an arbitrary directory. The information to be printed out should include:
a. File type.
b. Permissions.
c. User ID.
d. Group ID.
e. File size.
f. Time of last access.
g. File name.
h. Number of 512-type blocks allocated.
4. Write a program in C to traverse directories and print out the attributes associated with each entry in the directories traversed:
a. The starting directory can be arbitrary.
b. Print each directory entry on one line.
c. Print at least two attributes for each directory entry, plus the name.
d. For each directory, print out the absolute path name for that directory before printing out its contents.
e. Test access permission before getting into a directory.
希望大家不吝赐教。
附上代码的加分!!!!!!!
------解决方案--------------------
问题很简单,但没时间写,楼主你自己不会写吗
------解决方案--------------------
汗,e文
------解决方案--------------------
不是面试题吧,要是面试题除非让我带本参考资料.
stat的数据成员我可记不下来.
------解决方案--------------------
直接求代码的估计会被删掉。
删前留名。
------解决方案--------------------
自己写了第一道题大家看看,运行没有错误
#include "stdio.h "
#include "string.h "
void main()
{
FILE *fp,*fp1;
char *p;
int i,j=0,ch;
p=(char *)malloc(200);
for (i=0;i <200;i++)
{
p[i]= '\0 ';
1. Write a program in C to read in a text file and then print it out in reverse order. Pass the input file name to your program as a command line argument. The format of the input/output is up to you.
2. Write a program in C that appends information to an existing file. After you have finished processing your input data, proofread the information entered and make necessary changes needed if any typographical error is detected. To make it uniform, show and update contents one line at a time. You may use temporary file(s) in solving this problem, even though it is not encouraged.
3. Write a program in C to print out the status of an entry in an arbitrary directory. The information to be printed out should include:
a. File type.
b. Permissions.
c. User ID.
d. Group ID.
e. File size.
f. Time of last access.
g. File name.
h. Number of 512-type blocks allocated.
4. Write a program in C to traverse directories and print out the attributes associated with each entry in the directories traversed:
a. The starting directory can be arbitrary.
b. Print each directory entry on one line.
c. Print at least two attributes for each directory entry, plus the name.
d. For each directory, print out the absolute path name for that directory before printing out its contents.
e. Test access permission before getting into a directory.
希望大家不吝赐教。
附上代码的加分!!!!!!!
------解决方案--------------------
问题很简单,但没时间写,楼主你自己不会写吗
------解决方案--------------------
汗,e文
------解决方案--------------------
不是面试题吧,要是面试题除非让我带本参考资料.
stat的数据成员我可记不下来.
------解决方案--------------------
直接求代码的估计会被删掉。
删前留名。
------解决方案--------------------
自己写了第一道题大家看看,运行没有错误
#include "stdio.h "
#include "string.h "
void main()
{
FILE *fp,*fp1;
char *p;
int i,j=0,ch;
p=(char *)malloc(200);
for (i=0;i <200;i++)
{
p[i]= '\0 ';