View Code of Problem 50

#include<stdio.h>
#include<string.h>
int main()
{
 char str1[80];
  gets(str1);
  int flag=0;
 char str2[80];
  len=strlen(str1);
  for(i=0;i<len;i++)
  {
    if(str1[i]>'0'&&str1[i]<'9')
    {
       str2[j++]=str[i];
      flag=0;
      else if(flag==0)
      {
        str2[j++]='*';
        flag=1;
      }
    }
  
 }
 str[j]='\0';
   puts(str);
  return 0;
}

/*
Main.c: In function 'main':
Main.c:6:3: warning: 'gets' is deprecated [-Wdeprecated-declarations]
   gets(str1);
   ^~~~
In file included from Main.c:1:
/usr/include/stdio.h:583:14: note: declared here
 extern char *gets (char *__s) __wur __attribute_deprecated__;
              ^~~~
Main.c:9:3: error: 'len' undeclared (first use in this function)
   len=strlen(str1);
   ^~~
Main.c:9:3: note: each undeclared identifier is reported only once for each function it appears in
Main.c:10:7: error: 'i' undeclared (first use in this function)
   for(i=0;i<len;i++)
       ^
Main.c:14:13: error: 'j' undeclared (first use in this function)
        str2[j++]=str[i];
             ^
Main.c:14:18: error: 'str' undeclared (first use in this function); did you mean 'str2'?
        str2[j++]=str[i];
                  ^~~
                  str2
Main.c:16:7: error: expected '}' before 'else'
       else if(flag==0)
       ^~~~
Main.c:8:7: warning: variable 'str2' set but not used [-Wunused-but-set-variable]
  char str2[80];
       ^~~~
Main.c: At top level:
Main.c:24:6: error: 'j' undeclared here (not in a function)
  str[j]='\0';
      ^
Main.c:24:2: warning: data definition has no type or storage class
  str[j]='\0';
  ^~~
Main.c:24:2: warning: type defaults to 'int' in declaration of 'str' [-Wimplicit-int]
Main.c:25:4: warning: data definition has no type or storage class
    puts(str);
    ^~~~
Main.c:25:4: warning: type defaults to 'int' in declaration of 'puts' [-Wimplicit-int]
Main.c:25:4: warning: parameter names (without types) in function declaration
Main.c:26:3: error: expected identifier or '(' before 'return'
   return 0;
   ^~~~~~
Main.c:27:1: error: expected identifier or '(' before '}' token
 }
 ^
*/

Double click to view unformatted code.


Back to problem 50