i have a problem in which i have to remove char from strings by sending one string and char ata time to a function.
in the below code it works fine for first string but for each successive string initial characters are not passed ..like for second call first chatcter of string will not be passed and so on.
#include <stdio.h>
#include <string.h>
#define MAXLEN 100
void fnRemChar(char*,char);
int main(int argc,char *argv[])
{
system("clear");
int iNoOfStr;
char acInpStr[MAXLEN][MAXLEN];
char cChar;
printf("\nEnter number of strings to be entered(should not be greater than %d):",MAXLEN);
fflush(stdin);
scanf("%d",&iNoOfStr);
void (*REMOVE) (char* ,char);
/* REMOVE Pointer to Function fnRemChar */
REMOVE = fnRemChar;
for(int iCount=0;iCount<iNoOfStr;iCount++)
{
printf("\n ENTER %d String: ",iCount+1);
getchar();
fgets(acInpStr[iCount],MAXLEN,stdin);
fflush(stdout);
fflush(stdin);
}
printf("\n Enter character to be removed: ");
scanf("%c",&cChar);
for(int iCount=0;iCount<iNoOfStr;iCount++)
{
REMOVE(acInpStr[iCount],cChar);
}
}
void fnRemChar(char *acInpStr,char cChar)
{
char acFinalStr[MAXLEN];
int iCount=0,iCount1=0;
while(acInpStr[iCount]!='\0')
if(acInpStr[iCount] != cChar)
{
printf("\n %c",acInpStr[iCount]);
acFinalStr[iCount1]=acInpStr[iCount];
iCount1++;
}
iCount++;
}
printf("\n %s\n",acFinalStr);
}