![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| High Level Programming Post questions about C, C++, Java, SQL, and other programming languages here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| How to override my profile | mobile01 | High Level Programming | 0 | 11-30-2006 08:35 AM |
| date override | gerry shacter | AIX | 1 | 01-08-2006 10:42 PM |
| script to override natting | ppass | Shell Programming and Scripting | 9 | 03-22-2005 02:23 PM |
| Override | Mulo | IP Networking | 1 | 03-10-2002 06:56 PM |
| Override protection..... | Makaveli.2003 | UNIX for Dummies Questions & Answers | 1 | 01-23-2002 11:37 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Display Modes |
|
#1
|
|||
|
|||
|
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 |
| Forum Sponsor | ||
|
|
|
#2
|
|||
|
|||
|
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 Code:
#include "mystdio.h" |
|||
| Google The UNIX and Linux Forums |