Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

append..

what follows is a part of code i asked question about before thi code is possibly(!!)able to get a cells information but is still unable to collects data from each cell & pass it to the sensitive cells .plz help me with it ii may have just 2 or 3 days left..

(*some one has suggested to use structures for solving the problem but i dont know how to use it.***)
(input.txt is a given file composed of cells of mentioned before)
#include
#include
#include
#include
#include
//#include

void showpos(FILE *stream);

main(){

//struct stat statbuf;
int counter=1;
int i=0;
int k=0;
fpos_t pos1;
fpos_t pos2;
char string[2]={0};
char* data=(char*)malloc(10*sizeof(char*));
char* ptr=(char*)malloc(10*sizeof(char*));
//char* date=(char*)malloc(10*sizeof(char*));
char ch;
fpos_t filepos;
int j=0;
int m;
char* str;
//FILE* stream=fopen("input.txt","r+");
// fstat(fileno(stream), &statbuf);
// printf("Size of file in bytes: %ld
", statbuf.st_size);
str=(char*)malloc(sizeof(char*)*1500*4000);
//str=(char*)malloc(sizeof(statbuf));
FILE* stream=fopen("input.txt","r+");
/* if(isalpha(str[j])){j=j+2;
if(str[j]=='='){
j++;
while(!isalpha(str[j]),str[j]!=','){
data[j]=str[j];
j++; }
}
} */

fflush(stdin);
while(fgets(str,strlen((char*)stream)+1,stream)!=NULL)
printf("%s",str);

printf("
how many cells are you going to enter:");
scanf("%d",&m);
//printf("what is the cell you are looking for?");
while(j<=m){
printf("
what is the cell you are looking for?");
gets(string);
fseek(stream,0,SEEK_SET);

while(fscanf(stream,"%c",&ch)!=EOF&&i<2){
if((i==0&&string[0]==ch)||(i==1&&counter==string[1])||(i==1&&string[0]==ch&&counter!=string[1])){
if(string[0]==ch&&i==1&&counter!=string[1])
i=1;
else
i++;
fgetpos(stream,&pos1);
counter++;
}
if(i==1&&string[1]==ch){
fgetpos(stream,&pos2);
if((pos2-pos1)==1)
i++;
else{
i=0;
}
}

}

if(i==2){
showpos(stream);
while(fscanf(stream,"%c",&data[k])==0,k<10){
if(data[k]==',')
break;
printf("%c",data[k]); k++;}
}
fgetpos(stream,&filepos);
i=0;
k=0;
j++;
}
//j=0;
//i=0;
/* while(j<=10){
if(isalpha(data[j])){
ptr[j]=data[j];
// j++;
// ptr[j]=data[j];
fseek(stream,0,SEEK_SET);
if(isalpha(str[i]),str[i]==ptr[j]){j=j+2;
if(str[i]=='='){
j++;
while(!isalpha(str[i]),str[i]!=','){
date[i]=str[i];
printf("%c",date[i]);
i++; }
break; }
}
j++;
}

*/
fclose(stream);
free(str);
free(data);
free(ptr);
// free(date);
printf("
PRESS ANY KEY TO CONTINUE...");
getch();
}
void showpos(FILE *stream)
{
fpos_t pos;

/* display the current file pointer
position of a stream */
fgetpos(stream, &pos);
printf("
File position: %ld
", pos);
}
Sign In or Register to comment.