我需要你的帮助Banfa !!!! [英] i need your help Banfa!!!!

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

问题描述

问题是计算文件中的字母和序列。我的代码的第一件事就是读取文件,我创建的主要功能是使用2维数组计算字符和序列。

其中字符包含字母和空格。

我现在只是学习c语言,我对以下程序有疑问:

#define TRUE 1

#define 0 0

#define MAX_LENGTH 100000 / *从文件中读取的最大字符数* /

#include< stdio.h>

#include< ctype.h>


int Get_String_From_File(char filename [],char input [])

/ *从一个文件中读取字符(包括\ n) string * /

/ * filename应该给出现有文件的名称;

输入将返回该文件的内容* /

/ *如果文件打开失败则返回值0,否则返回1 * /

/ *最大值字符串的长度存储在MAX_LENGTH * /


{

int i = -1; / *将在使用前更新* /

char temp;

FILE * infile;


infile = fopen(filename ,r,;

if(infile == NULL){

printf("无法打开文件\%s \\\ \\ n \\ n,文件名;

返回FALSE;

}


do {

i ++ ;

输入[i] = fgetc(infile);

} while(输入[i]!= EOF&& i< MAX_LENGTH - 1&& ; input [i]!=''\ 0'');

如果(i == MAX_LENGTH - 1)/ *唯一停止的原因是MAX_LENGTH * /

fprintf(stderr,警告:达到此程序处理的文件的最大大小!\ n \ n);

input [i] =''\'''; / *字符串结束标记* /

fclose(infile);


返回TRUE; / *成功阅读文件* /

}

int main(无效)

{

int c,i ,j,空格,charArray [26] [26];


for(i = 0; i< 26; ++ i)/ * init array to zero * /

charArray [i] [j] = 0;

for(j = 0; j< 26; ++ j)

charArray [j] = 0;

而((c = getchar())!= EOF)/ *计算字母* /

if(isupper(c)&& islower( c))

++ char [c - > ''A''&& c - > ''''&& C-> ;? ?];

for(i = 0; i< 26; ++ i)

if(i%6 == 0)

for(j = 0; j< 26; ++ j)

if(j%6 == 0){

printf(" \ n");

printf("%4c%4c:%3d%3d",''A''||''a''+ i + j,letter [i] [j]); < br $>
}

printf(" \ n \ n");

返回0;

}

the problem is to count the letters and sequence from a file. the fist thing of my code is to read file and in the main function i create is to count the characters and sequence by using 2 dimension array.
where the character include letters and spaces.
I am just learning c language at the moment, i have problem with following program:
#define TRUE 1
#define FALSE 0
#define MAX_LENGTH 100000 /* Max number of chars read from file */
#include <stdio.h>
#include <ctype.h>

int Get_String_From_File(char filename[], char input[])
/* Reads in characters (including \n) from a file as one long string */
/* filename should give name of an existing file;
input will return contents of that file */
/* Return value 0 if file open fails, 1 otherwise */
/* Maximum length of string is stored in MAX_LENGTH */

{
int i = -1; /* will be updated before being used */
char temp;
FILE *infile;

infile = fopen(filename,"r");
if (infile == NULL) {
printf("Failed to open file \"%s\"\n",filename);
return FALSE;
}

do {
i++;
input[i] = fgetc(infile);
} while (input[i] != EOF && i < MAX_LENGTH - 1 && input[i] != ''\0'');
if (i == MAX_LENGTH - 1) /* only reason for stopping is MAX_LENGTH */
fprintf(stderr,"Warning: Reached maximum size of file handled by this program!\n\n");
input[i] = ''\0''; /* end of string marker*/
fclose(infile);

return TRUE; /* Successfully read file */
}
int main(void)
{
int c, i, j, spaces,charArray[26][26];

for (i=0; i<26; ++i) /* init array to zero */
charArray[i][j] = 0;
for( j= 0; j<26; ++j)
charArray[j] = 0;
while((c = getchar()) != EOF) /* count the letter */
if(isupper(c) && islower(c))
++char[c -> ''A'' && c -> ''a'' && c->? ?];
for (i=0; i<26; ++i)
if(i%6==0)
for ( j= 0; j<26; ++j)
if(j%6==0) {
printf("\n");
printf("%4c%4c:%3d%3d", ''A'' || ''a'' +i +j, letter[i][j]);
}
printf("\n\n");
return 0;
}

推荐答案


问题是计算文件中的字母和序列。我的代码的第一件事就是读取文件,我创建的主要功能是使用2维数组计算字符和序列。

其中字符包含字母和空格。

我现在只是学习c语言,我对以下程序有疑问:

#define TRUE 1

#define 0 0

#define MAX_LENGTH 100000 / *从文件中读取的最大字符数* /

#include< stdio.h>

#include< ctype.h>


int Get_String_From_File(char filename [],char input [])

/ *从一个文件中读取字符(包括\ n) string * /

/ * filename应该给出现有文件的名称;

输入将返回该文件的内容* /

/ *如果文件打开失败则返回值0,否则返回1 * /

/ *最大值字符串的长度存储在MAX_LENGTH * /


{

int i = -1; / *将在使用前更新* /

char temp;

FILE * infile;


infile = fopen(filename ,r,;

if(infile == NULL){

printf("无法打开文件\%s \\\ \\ n \\ n,文件名;

返回FALSE;

}


do {

i ++ ;

输入[i] = fgetc(infile);

} while(输入[i]!= EOF&& i< MAX_LENGTH - 1&& ; input [i]!=''\ 0'');

如果(i == MAX_LENGTH - 1)/ *唯一停止的原因是MAX_LENGTH * /

fprintf(stderr,警告:达到此程序处理的文件的最大大小!\ n \ n);

input [i] =''\'''; / *字符串结束标记* /

fclose(infile);


返回TRUE; / *成功阅读文件* /

}

int main(无效)

{

int c,i ,j,空格,charArray [26] [26];


for(i = 0; i< 26; ++ i)/ * init array to zero * /

charArray [i] [j] = 0;

for(j = 0; j< 26; ++ j)

charArray [j] = 0;

而((c = getchar())!= EOF)/ *计算字母* /

if(isupper(c)&& islower( c))

++ char [c - > ''A''&& c - > ''''&& C-> ;? ?];

for(i = 0; i< 26; ++ i)

if(i%6 == 0)

for(j = 0; j< 26; ++ j)

if(j%6 == 0){

printf(" \ n");

printf("%4c%4c:%3d%3d",''A''||''a''+ i + j,letter [i] [j]); < br $>
}

printf(" \ n\ n");

返回0;

}
the problem is to count the letters and sequence from a file. the fist thing of my code is to read file and in the main function i create is to count the characters and sequence by using 2 dimension array.
where the character include letters and spaces.
I am just learning c language at the moment, i have problem with following program:
#define TRUE 1
#define FALSE 0
#define MAX_LENGTH 100000 /* Max number of chars read from file */
#include <stdio.h>
#include <ctype.h>

int Get_String_From_File(char filename[], char input[])
/* Reads in characters (including \n) from a file as one long string */
/* filename should give name of an existing file;
input will return contents of that file */
/* Return value 0 if file open fails, 1 otherwise */
/* Maximum length of string is stored in MAX_LENGTH */

{
int i = -1; /* will be updated before being used */
char temp;
FILE *infile;

infile = fopen(filename,"r");
if (infile == NULL) {
printf("Failed to open file \"%s\"\n",filename);
return FALSE;
}

do {
i++;
input[i] = fgetc(infile);
} while (input[i] != EOF && i < MAX_LENGTH - 1 && input[i] != ''\0'');
if (i == MAX_LENGTH - 1) /* only reason for stopping is MAX_LENGTH */
fprintf(stderr,"Warning: Reached maximum size of file handled by this program!\n\n");
input[i] = ''\0''; /* end of string marker*/
fclose(infile);

return TRUE; /* Successfully read file */
}
int main(void)
{
int c, i, j, spaces,charArray[26][26];

for (i=0; i<26; ++i) /* init array to zero */
charArray[i][j] = 0;
for( j= 0; j<26; ++j)
charArray[j] = 0;
while((c = getchar()) != EOF) /* count the letter */
if(isupper(c) && islower(c))
++char[c -> ''A'' && c -> ''a'' && c->? ?];
for (i=0; i<26; ++i)
if(i%6==0)
for ( j= 0; j<26; ++j)
if(j%6==0) {
printf("\n");
printf("%4c%4c:%3d%3d", ''A'' || ''a'' +i +j, letter[i][j]);
}
printf("\n\n");
return 0;
}



如果Banfa去维多利亚瀑布钓鱼之旅并决定在那里度过一个月,那么有六个人可以帮助你周围但是他们认为他们不是Banfa ......

What if Banfa has gone away for fishing trip in the Victoria falls and decides to spend a month there and there are half a dozen people who can help you who are around but seeing as they would that they are not Banfa...



如果Banfa去维多利亚瀑布钓鱼之旅并决定怎么办?在那里度过一个月,有六个人可以帮助你身边,但他们会看到他们不是班法...
What if Banfa has gone away for fishing trip in the Victoria falls and decides to spend a month there and there are half a dozen people who can help you who are around but seeing as they would that they are not Banfa...



非常真实,我怀疑r035198x可能已经回答了你的问题。

无论如何你已经给出了你正在编写的程序的规范,你已经给出了代码,你似乎没有说明你遇到的问题是什么。

Very true, I suspect r035198x probably could have answered you problem.

Anyway you have given the specification of the program you are writing, you have given the code, you do not seem to have stated what the problem you are having is.



非常正确,我怀疑r035198x可能已经回答了你的问题。


无论如何你已经给出了规范你正在编写的程序,你已经给出了代码,你似乎没有说明你遇到的问题是什么。
Very true, I suspect r035198x probably could have answered you problem.

Anyway you have given the specification of the program you are writing, you have given the code, you do not seem to have stated what the problem you are having is.



希望你不要离开互联网当然是Banfa!

我只是想知道是什么OP正试图用类似

Hopefully you won''t be taking a holiday away from the internet of course Banfa!
I''m just wondering what the OP is trying to do with a statement like

展开 | 选择 | Wrap | 行号


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

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