View Code of Problem 101

#include<stdio.h>
#include<string.h>
#include<math.h>
#include<ctype.h>
int main()
{
	char a[100];
	while(gets(a)!=NULL)
	{
		char b[100]={'\0'},c[100]={'\0'};
		int k=0,i,t=0;
		for(i=strlen(a)-1;i>=0;i--)
		{
			if(isdigit(a[i]))
			b[k++]=a[i];
		}
		for(i=0;i<k;i++)
		{
			c[t++]=b[i];
			if(i%3==2)
			c[t++]=',';
		}
		strrev(c);
		puts(c);
	}
	return 0;
 } 
/*
Main.c: In function 'main':
Main.c:8:2: warning: 'gets' is deprecated [-Wdeprecated-declarations]
  while(gets(a)!=NULL)
  ^~~~~
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:23:3: warning: implicit declaration of function 'strrev'; did you mean 'strlen'? [-Wimplicit-function-declaration]
   strrev(c);
   ^~~~~~
   strlen
/usr/bin/ld: /tmp/ccijfG1U.o: in function `main':
Main.c:(.text.startup+0x29): warning: the `gets' function is dangerous and should not be used.
/usr/bin/ld: Main.c:(.text.startup+0x164): undefined reference to `strrev'
collect2: error: ld returned 1 exit status
*/

Double click to view unformatted code.


Back to problem 101