use ggg
This commit is contained in:
parent
5dba0df6ac
commit
dd35c14a17
52
client/func/readtext.c
Normal file
52
client/func/readtext.c
Normal file
@ -0,0 +1,52 @@
|
|||||||
|
void readtext(){
|
||||||
|
FILE *f;
|
||||||
|
int i=0;
|
||||||
|
int num_text=0;
|
||||||
|
char a;
|
||||||
|
int i_text=0;
|
||||||
|
int acount_text=0;
|
||||||
|
|
||||||
|
//acount the num of char and row
|
||||||
|
f=fopen(name,"r+");
|
||||||
|
a=fgetc(f);
|
||||||
|
for(;a!=EOF;){
|
||||||
|
if(a=='\n'){
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
num_text++;
|
||||||
|
a=fgetc(f);
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
row_text=i;
|
||||||
|
|
||||||
|
//write the text to []
|
||||||
|
text=(char *)malloc(sizeof(char)*(num_text+1));
|
||||||
|
ana_text=(int *)malloc(sizeof(int)*(row_text+1));
|
||||||
|
|
||||||
|
f=fopen(name,"r+");
|
||||||
|
a=fgetc(f);
|
||||||
|
for(i=0;i<num_text;i++){
|
||||||
|
text[i]=a;
|
||||||
|
if(a=='\n'&&i_text<=row_text){
|
||||||
|
*(ana_text+i_text)=acount_text;
|
||||||
|
acount_text=0;
|
||||||
|
i_text++;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
acount_text++;
|
||||||
|
}
|
||||||
|
a=fgetc(f);
|
||||||
|
}
|
||||||
|
text[i]='\0';
|
||||||
|
*(ana_text+i_text)='\0';
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
ana_row=(int *)malloc(sizeof(int)*(row_text+1));
|
||||||
|
row_display=0;
|
||||||
|
|
||||||
|
for(i=0;i<row_text;i++){
|
||||||
|
*(ana_row+i)=*(ana_text+i)/COLS+1;
|
||||||
|
row_display+=*(ana_row+i);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -28,7 +28,9 @@ void trans_client(){
|
|||||||
|
|
||||||
void trans_c_send(char *name){
|
void trans_c_send(char *name){
|
||||||
char *name;
|
char *name;
|
||||||
|
char *s;
|
||||||
name=(char *)malloc(sizeof(char)*128);
|
name=(char *)malloc(sizeof(char)*128);
|
||||||
|
s=(char *)malloc(1024*sizeof(char));
|
||||||
int num_name;
|
int num_name;
|
||||||
memset(name,0,128*sizeof(char));
|
memset(name,0,128*sizeof(char));
|
||||||
printf("input the name of file:");
|
printf("input the name of file:");
|
||||||
@ -36,12 +38,28 @@ void trans_c_send(char *name){
|
|||||||
num_name=strlen(name);
|
num_name=strlen(name);
|
||||||
send(sockad,name,num_name,0);
|
send(sockad,name,num_name,0);
|
||||||
|
|
||||||
|
FILE *f;
|
||||||
|
int num_text=0;
|
||||||
|
char a;
|
||||||
|
|
||||||
|
f=fopen(name,"r+");
|
||||||
|
a=fgetc(f);
|
||||||
|
for(;a!=EOF;){
|
||||||
|
num_text++;
|
||||||
|
a=fgetc(f);
|
||||||
|
}
|
||||||
|
fclose(f);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
free(name);
|
free(name);
|
||||||
|
|
||||||
}
|
}
|
||||||
void trans_c_get(char *name){
|
void trans_c_get(char *name){
|
||||||
char *name;
|
char *name;
|
||||||
|
char *s;
|
||||||
name=(char *)malloc(sizeof(char)*128);
|
name=(char *)malloc(sizeof(char)*128);
|
||||||
|
s=(char *)malloc(1024*sizeof(char));
|
||||||
int num_name;
|
int num_name;
|
||||||
memset(name,0,128*sizeof(char));
|
memset(name,0,128*sizeof(char));
|
||||||
printf("input the name of file:");
|
printf("input the name of file:");
|
||||||
@ -67,3 +85,4 @@ void itc(int num_name,char *num_name_char){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user