override the function in C

hi ,

greetings ,

I have one doubt reg the C functions .

I have a program sample.c , in which i have function name scanf , which reads a a variable and prints the variable inside the function .
this scanf is nothing to do with C library function scanf , but i would like to use only user defined c function scanf .

when it is compiling , it is throwing error indicating scanf args not matching becos compile checks for stdio.h header file for syntax of scanf .

To put in a simple statement , i would like to override a system function and make my c program to take function which i wrote which has same name .

It can be a similar concept of function overloading in C .

For example :
in case macros i can overide any macro inside my program just by doing #undef name
#define name "unix"

it works for macros ,

in same line how to override the function?

Many Thanks in advance !

Thanks
Naren

The error comes from the fact that cpp included stdio.h which automatically brings a function prototype for sscanf into the file the compiler sees.

Suggestions:

  1. Park your sscanf() module in a separate source file and place every module that calls your sscanf() in that same separate file. In the same file, declare any other function from stdio.h as extern. If you have only one source file, remove stdio.h from the include list and declare everything as extern. You could also make a LOCAL copy of stdio.h and remove references to sscanf from it, rename it, then
#include "mystdio.h"
  1. Rename your sscanf() as mysscanf()