一道猥琐的题目

记得同学 上次发了一道题,突然记起,今天看了下答案,果然猥琐。

题目如下:

#include "stdio.h" void print() { * } void main() { } //要求在*号处添加语句,程序输出hello,world!  

 

 

因为太猥琐,直接放答案:

1.猥琐注释流(VC6下报fatal error C1071: unexpected end of file found in comment错误)

#include "stdio.h" void print() { } void main(){puts("HelloWorld");} /* } void main() { }

 

 

2.猥琐#define流

#include "stdio.h" void print() { #define main main(){printf("Hello World!/n");} void empty } void main() { }

 

 

3.猥琐API流

#include "stdio.h" void print() { #pragma comment(linker,"/entry:print") #pragma comment(lib,"kernel32.lib")//加上这句,免得某些XX说我猥琐 #define HANDLE unsigned long #define WINAPI __stdcall #define DWORD unsigned long #define BOOL unsigned long #define STD_OUTPUT_HANDLE ((DWORD)-11) DWORD dw=0; HANDLE WINAPI GetStdHandle(DWORD nStdHandle); BOOL WINAPI WriteFile(HANDLE hFile,void *lpBuffer,DWORD nNumberOfBytesToWrite,DWORD* lpNumberOfBytesWritten,HANDLE *lpOverlapped); WriteFile(GetStdHandle(STD_OUTPUT_HANDLE),"Hello,world!/n",sizeof("Hello,world!/n"),&dw,NULL); } void main() { }

这种方法报错:

unresolved external symbol "unsigned long __stdcall WriteFile(unsigned long,void *,unsigned long,unsigned long *,unsigned long *)" (?WriteFile@@YGKKPAXKPAK1@Z)

unresolved external symbol "unsigned long __stdcall GetStdHandle(unsigned long)

应该是通过直接操作标准输入输出流的方法。

 

 

4.猥琐构造函数流

//猥琐构造函数流(/* */里的内容就是*的内容) #include "stdio.h" void print() { } class cls{ public: cls(){ printf("hello world/n") ; } } ; cls mycls ; void fun(){ } void main() { }

 

据说题目来自电子科大,找不到原始出处了~

 

 

你可能感兴趣的:(api,Class,fun,output,linker,winapi)