C Board  

Go Back   C Board > Community Boards > Contests Board

Reply
 
LinkBack Thread Tools Display Modes
Old 12-02-2005, 06:01 PM   #1
VA National Guard
 
The Brain's Avatar
 
Join Date: May 2004
Location: Manassas, VA USA
Posts: 902
bit o' fun

Code:
#include <stdio.h>
 
int main(void) {
   int i = 5;
   /* Add a line of code here to make the printf() below output 5 */
   i = 8;
   printf("%d\n", i);
   return 0;
}
__________________
  • "Problem Solving C++, The Object of Programming" -Walter Savitch
  • "Data Structures and Other Objects using C++" -Walter Savitch
  • "Assembly Language for Intel-Based Computers" -Kip Irvine
  • "Programming Windows, 5th edition" -Charles Petzold
  • "Visual C++ MFC Programming by Example" -John E. Swanke
  • "Network Programming Windows" -Jones/Ohlund
  • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
  • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
The Brain is offline   Reply With Quote
Old 12-02-2005, 06:15 PM   #2
carry on
 
JaWiB's Avatar
 
Join Date: Feb 2003
Location: Seattle, WA
Posts: 1,971
Umm:
Code:
#include <stdio.h>
 
int main(void) {
   int i = 5;
   #define printf printf("5\n");   
   i = 8;
   printf("%d\n", i);
   return 0;
}
__________________
"Think not but that I know these things; or think
I know them not: not therefore am I short
Of knowing what I ought."
-John Milton, Paradise Regained (1671)

"Work hard and it might happen."
-XSquared
JaWiB is offline   Reply With Quote
Old 12-02-2005, 06:25 PM   #3
VA National Guard
 
The Brain's Avatar
 
Join Date: May 2004
Location: Manassas, VA USA
Posts: 902
anyone come up with anything different..??
__________________
  • "Problem Solving C++, The Object of Programming" -Walter Savitch
  • "Data Structures and Other Objects using C++" -Walter Savitch
  • "Assembly Language for Intel-Based Computers" -Kip Irvine
  • "Programming Windows, 5th edition" -Charles Petzold
  • "Visual C++ MFC Programming by Example" -John E. Swanke
  • "Network Programming Windows" -Jones/Ohlund
  • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
  • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
The Brain is offline   Reply With Quote
Old 12-02-2005, 06:29 PM   #4
Dump Truck Internet
 
valis's Avatar
 
Join Date: Jul 2005
Posts: 357
Same idea:
Code:
#include <stdio.h>

int main(void)
{
	int i = 5;
	#define jab \
	i = 8;
	printf("%d\n", i);

	return(0);
}
or with two lines (under the assumption your x86)
Code:
#include <stdio.h>

int main(void)
{
	int i = 5;
	__asm add ebp,4
	i = 8;
	__asm sub ebp,4
	printf("%d\n", i);

	return(0);
}
valis is offline   Reply With Quote
Old 12-02-2005, 06:39 PM   #5
VA National Guard
 
The Brain's Avatar
 
Join Date: May 2004
Location: Manassas, VA USA
Posts: 902
used more than one line..!!! :P
__________________
  • "Problem Solving C++, The Object of Programming" -Walter Savitch
  • "Data Structures and Other Objects using C++" -Walter Savitch
  • "Assembly Language for Intel-Based Computers" -Kip Irvine
  • "Programming Windows, 5th edition" -Charles Petzold
  • "Visual C++ MFC Programming by Example" -John E. Swanke
  • "Network Programming Windows" -Jones/Ohlund
  • "Sams Teach Yourself Game Programming in 24 Hours" -Michael Morrison
  • "Mathmatics for 3D Game Programming & Computer Graphics" -Eric Lengyel
The Brain is offline   Reply With Quote
Old 12-02-2005, 07:31 PM   #6
...
 
kermit's Avatar
 
Join Date: Jan 2003
Posts: 1,190
Code:
#include <stdio.h>

int main(void)
{
        int i = 5;

        if (i == 0)
                i = 8;

        printf("%d\n", i);
        return 0;
}
I know its kind of cheesey...
kermit is offline   Reply With Quote
Old 12-02-2005, 08:29 PM   #7
Tropical Coder
 
Darryl's Avatar
 
Join Date: Mar 2005
Location: Cayman Islands
Posts: 503
Code:
#include <stdio.h>
 

int main(void) {
   int i = 5;
   while(false)
   i = 8;
   printf("%d\n", i);
   return 0;
}

Last edited by Darryl; 12-02-2005 at 08:33 PM.
Darryl is offline   Reply With Quote
Old 12-02-2005, 08:30 PM   #8
Registered User
 
Join Date: Jan 2005
Posts: 847
Some more x86 asm.
Code:
#include <stdio.h>
 
int main(void) {
   int i = 5;
a: __asm jmp a+12
   i = 8;
   printf("%d\n", i);
   return 0;
}
Quantum1024 is offline   Reply With Quote
Old 12-02-2005, 08:52 PM   #9
Anti-Poster
 
Join Date: Feb 2002
Posts: 1,212
Bah...why not?
Code:
#include <stdio.h>
 
int main(void) 
{
   int i = 5;
   return printf("5"),0;
   i = 8;
   printf("%d\n", i);
   return 0;
}
__________________
Rule #1: Every rule has exceptions

Traveller's Dilemma Contest Site - Results posted!
pianorain is offline   Reply With Quote
Old 12-08-2005, 04:40 PM   #10
Registered User
 
kryptkat's Avatar
 
Join Date: Dec 2002
Posts: 409
Code:
#include <stdio.h>
 
int main(void) {
   int i = 5;
   /* Add a line of code here to make the printf() below output 5 meow! 
   i = 8; */
   printf("%d\n", i);
   return 0;
}
kryptkat is offline   Reply With Quote
Old 12-09-2005, 02:43 PM   #11
Supermassive black hole
 
ahluka's Avatar
 
Join Date: Jul 2005
Location: South Wales, UK
Posts: 1,709
Quote:
Originally Posted by Quantum1024
Some more x86 asm.
Code:
#include <stdio.h>
 
int main(void) {
   int i = 5;
a: __asm jmp a+12
   i = 8;
   printf("%d\n", i);
   return 0;
}
Does that mean "i = 8;" is 12 bytes long in the .exe?
__________________
Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

- Mike McShaffry
ahluka is offline   Reply With Quote
Old 12-09-2005, 07:24 PM   #12
Registered User
 
Join Date: Aug 2001
Posts: 244
no,

Code:
a: __asm jmp a+12
i = 8;
is assumed to be 12 bytes long i = 8; AND the jmp
__________________
signature under construction
Raven Arkadon is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
copying or concatinating string from 1st bit, leaving 0th bit spanian2708 C Programming 3 11-10-2005 10:53 AM
porting application from 32 bit to 64 bit error gandalf_bar Linux Programming 1 09-14-2005 09:20 AM
Bit processing in C eliomancini C Programming 8 06-07-2005 10:54 AM
Bit Manipulation Questions CPPNewbie C++ Programming 7 08-12-2003 02:17 PM
Array of boolean DMaxJ C++ Programming 11 10-25-2001 11:45 PM


All times are GMT -6. The time now is 08:50 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.3.0 RC2

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22