Hi,

Is this a valid while loop? :

while((grid[tr][tc]=='0'||grid[tr][tc]==s[i]) && tr<row && count<strlen(s))
       { ++count;
         ++tr;
       }

Although the full program compiles fine, but sometimes my program crashes during runtime giving me a "Access violation(Segmentation Fault)" error and the debugger points to this loop statement... By the way, I'm using dev c++ ...

Regards,

I suggest to write it as

while((tr < row) && (grid[tr][tc]=='0'||grid[tr][tc]==s[i]) && (count<strlen(s)))
       { ++count;
         ++tr;
       }

If tr < row fails, grid[tr] will not be computed :)

WOW!! You suggestion worked!! My program no more crashes during runtime ! THANKS!

hehe !

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.