View Code of Problem 55

#include<stdio.h>
#include<string.h>
int main(){
  char str[100],c;
  int num=0;
  gets(str);
  getchar(c);
  for(int i=0;i<strlen(str);i++){
    if(str[i]==c) num++
      else str[i-num]=str[i];
      }
  puts(str);
  return 0;
}
/*
Main.c: In function 'main':
Main.c:6:3: warning: 'gets' is deprecated (declared at /usr/include/stdio.h:638) [-Wdeprecated-declarations]
   gets(str);
   ^
Main.c:7:3: error: too many arguments to function 'getchar'
   getchar(c);
   ^
In file included from Main.c:1:0:
/usr/include/stdio.h:538:12: note: declared here
 extern int getchar (void);
            ^
Main.c:10:7: error: expected ';' before 'else'
       else str[i-num]=str[i];
       ^
*/

Double click to view unformatted code.


Back to problem 55