holes:wrong answer..not able to find the reason..pleazzz help!!

#include<stdio.h>
#include<string.h>
int main()
{
int tc,c,i,flag=0;
scanf("%d",&tc);
for(c=0;c<=tc;c++)
{
char str[100];
char string;
string=gets(str);
for(i=0;i<=strlen(string);i++)
{
if(
(string+i)==‘A’||(string+i)==‘D’||(string+i)==‘O’||(string+i)==‘P’||(string+i)==‘R’||(string+i)==‘Q’)
flag++;
else if(
(string+i)==‘B’)
flag=flag+2;
}
printf("%d\n",flag);
flag=0;
}
return 0;
}

I tried your code and it prints 0 as the first number - ur9p4N - Online C++ Compiler & Debugging Tool - Ideone.com

thanx fr correcting me…hw shud i modify it…plz suggest…

Hello @rtandon90210,

You need to see that we like to help newbies here, but, if we do all the work for you and debug your code for you, you won’t learn much…

From the title of your question you say you can’t find the reason for WA, but, did you even tested your code locally?

Because, as @betlista pointed out, you are printing a 0 at the beginning of the output, which would clearly be something you could have noticed if you had tested your code locally even with trivial examples… Please always expose your questions clearly and concisely so we can help you in the best possible manner, as people may get demotivated to help you if they see you are just here for the AC status and not because you are really struggling…

With this said… you can use scanf("%s",str); to read a string from stdin and you don’t need dynamic strings here…

Best regards,

Bruno