Friday

C Program To Print A String Without Using Any Output Statements

This program can be used to print a string without using any output statements such as printf,puts etc.However this program only works in 16-bit mode since it directly writes to VDU Memory

#include<stdio.h>
#include<conio.h>
char str[]="Hello Srikanth";
char far *v=(char far *)0xb8000000;
void main()
{
int i;
for(i=0;i<14;i++)
{
*v=str[i];
v+=2;
}
getch();
}

Readers Who Read This Page, Also Read:

C Program To Print A Character Without Using Any Output Statements

C Program To Remove Comments & Blank Lines From A Valid C Program

Program To Print It's Own Source Code

Self Destructing Program In C

2 comments:

Anonymous said...

if you use linux:


int main()
{
char code[]= "\xeb\x18\x59\xb8\x04\x00\x00\x00\x31\xdb"
"\xba\x18\x00\x00\x00\xcd\x80\xb8\x01\x00\x00\x00\x31\xdb"
"\xcd\x80\xe8\xe3\xff\xff\xff\x49\x27\x6d\x20\x66\x6f\x72\x6d\x61"
"\x74\x74\x69\x6e\x67\x20\x6d\x79\x20\x62\x72\x61\x69\x6e\x0a" ;
int (*func)();
func = (int (*)()) code;
(int)(*func)();

return 0;
}

zer0c00l said...

hey buddy that was awesome
but please cn u also explain the logic