本文介绍了重新定义具有相同名称的函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好 我想在标题stdio.h中重新定义一个函数getchar(),但我不知道我应该怎么做.b br />hi allI want to redefine a function getchar() in header stdio.h ,but I don''tknow what should I do.推荐答案 想要别的东西。重新定义标准库函数是一个糟糕的想法。 但是如果你只是想能够使用不同的名称,那就没关系。 做这样的事情: #include< stdio.h> #define paytamTriesToGetACharFromStdin getchar int main(无效) { int ch = 0; while( (ch = paytamTriesToGetACharFromStdin())!= EOF) { putchar(ch); } 返回0; } - Richard Heathfield Usenet是一个奇怪的地方 - dmr 29/7/1999 http://www.cpax.org.uk 电子邮件:rjh在上面的域名(但显然放弃了www)Want something else instead. Redefining standard library functions is a badidea.But if you just want to be able to use a different name for it, that''s fine.Just do something like this:#include <stdio.h>#define paytamTriesToGetACharFromStdin getcharint main(void){int ch = 0;while((ch = paytamTriesToGetACharFromStdin()) != EOF){putchar(ch);}return 0;}--Richard Heathfield"Usenet is a strange place" - dmr 29/7/1999 http://www.cpax.org.ukemail: rjh at above domain (but drop the www, obviously) 您应该在专门针对您的特定编译器的新闻组中询问 套件,因为在一般情况下,ISO C标准声明这将导致未定义的行为。 RichardYou should ask in a newsgroup dedicated to your particular compilersuite, since in the general case the ISO C Standard declares this tocause undefined behaviour.Richard 打开头文件stdio.h - / usr / include / stdi o.h并将其更改为 无论你想要什么。 完成。open the header file stdio.h - /usr/include/stdio.h and change it towhatever u want.done. 这篇关于重新定义具有相同名称的函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!