Wrong puzzle. or please help me out why program is wrong
#include
#include
#include
unsigned int DistanceBWZeroAndOne(unsigned int i,unsigned int j,unsigned int Height,unsigned int Width,char fileData[Height][Width])
{
unsigned int Valid = (i
|| (j>0 && (fileData[i][j-1]!=48)) || ((j+1)
{
noOfClicks = tempNoOfClicks;
}
}
}
}
return(noOfClicks);
}
unsigned int OpenFile(const char FileName[])
{
FILE *fp;
unsigned int Height,Width;
unsigned int noOfClicks=0;
char *OutputFileName;
unsigned int FileNameSize = strlen(FileName) +2;
fp = fopen(FileName,"r");
OutputFileName = (char *) malloc(FileNameSize);
strcpy(OutputFileName,FileName);
strcpy(&OutputFileName[strlen(FileName)-2],"out");
OutputFileName[strlen(FileName) +1]='\0';
if(fp == NULL)
{
printf("unable to open file\n");
exit(1);
}
else
{
fscanf(fp,"%d %d",&Height,&Width);
noOfClicks = FindTheLongestDistanceFrom0(fp,Height,Width);
fclose(fp);
fp = fopen(OutputFileName,"w");
fprintf(fp,"%d",noOfClicks);
fclose(fp);
return(noOfClicks);
}
}
int main(int argc, char *argv[]) {
if(argc == 1)
{
printf("the input format should be file path\n");
return -1;
}
else
{
printf("%d = No of Clicks\n",OpenFile(argv[1]));
return 0;
}
}
usage
./fillTool a.in
result will be in a.out
No comments:
Post a Comment
తెలుగులో వ్రాయడానికి http://www.google.com/ime/transliteration/ ఉపయోగించండి.