Click here to Skip to main content
15,921,694 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralC++ Question. Pin
WREY23-Sep-03 10:51
WREY23-Sep-03 10:51 
GeneralRe: C++ Question. Pin
Joaquín M López Muñoz23-Sep-03 10:56
Joaquín M López Muñoz23-Sep-03 10:56 
GeneralUnderstood!! Pin
WREY23-Sep-03 11:22
WREY23-Sep-03 11:22 
GeneralRe: Understood!! Pin
Blake Coverett23-Sep-03 15:46
Blake Coverett23-Sep-03 15:46 
GeneralRe: Understood!! Pin
jhwurmbach24-Sep-03 0:13
jhwurmbach24-Sep-03 0:13 
GeneralOPENGL EXAMPLE TO DISPLAY JAPANESE/CHIENSE Pin
sdfdsfa23-Sep-03 10:39
sdfdsfa23-Sep-03 10:39 
GeneralList Exchange Servers Pin
Robert M Greene23-Sep-03 10:37
Robert M Greene23-Sep-03 10:37 
Generaldouble problem Pin
Sirrius23-Sep-03 10:32
Sirrius23-Sep-03 10:32 
I have a struct with a int and double in it. I can initialize them both just fine from inside the main. The problem arises when I try to convert the double to binary toward the end of the code, it seems to cause an error at: if((c.i) & (1 << bits)) on the c.i and I don't have a clue why. Only the double/float causes this error, all the other go throught just fine.


#include <stdio.h>
#include "typedefs.h"

typedef struct
{
double i;
long x;
}myStruct;


void main()
{
	myStruct c;
  
	int space = 0;
	int bits = 0;
	int on = 1;
	int off = 0;
	
	scanf("%d",&c.x);
	//printf("%d\n",c.x);

		for(bits=31; bits>=0; --bits)
	{
		
		if(space == 8)
		{
			printf(" ");
			space = 0;
		}
		if(c.x & (1 << bits))
		
			printf("%d",on);
		else
			printf("%d",off);
		++space;
	}
	printf("\n");

	scanf("%lf",&c.i);
	space = 0;

	for(bits=7; bits>=0; --bits)
	{
		
		if(space == 8)
		{
			printf(" ");
			space = 0;
		}
		if((c.i) & (1 << bits))
		
			printf("%d",on);
		else
			printf("%d",off);
		++space;
	}
	printf("\n");

GeneralRe: double problem Pin
Joaquín M López Muñoz23-Sep-03 11:04
Joaquín M López Muñoz23-Sep-03 11:04 
GeneralRe: double problem Pin
Sirrius23-Sep-03 13:18
Sirrius23-Sep-03 13:18 
GeneralRe: double problem Pin
David Crow23-Sep-03 16:58
David Crow23-Sep-03 16:58 
GeneralRe: double problem Pin
Sirrius23-Sep-03 18:19
Sirrius23-Sep-03 18:19 
GeneralOrdered Linked List Pin
Sirrius23-Sep-03 10:01
Sirrius23-Sep-03 10:01 
GeneralRe: Ordered Linked List Pin
Joaquín M López Muñoz23-Sep-03 11:00
Joaquín M López Muñoz23-Sep-03 11:00 
GeneralRe: Ordered Linked List Pin
David Crow23-Sep-03 11:20
David Crow23-Sep-03 11:20 
GeneralRe: Ordered Linked List Pin
Sirrius23-Sep-03 13:20
Sirrius23-Sep-03 13:20 
GeneralRC2 encryption interoperability between VC++ and VB.NET Pin
sheelag23-Sep-03 8:49
sheelag23-Sep-03 8:49 
GeneralCDaoDatabase and CDaoRecordset for MS Access 2000 Pin
DionChen23-Sep-03 8:00
DionChen23-Sep-03 8:00 
GeneralRe: CDaoDatabase and CDaoRecordset for MS Access 2000 Pin
JWood23-Sep-03 9:57
JWood23-Sep-03 9:57 
GeneralRe: CDaoDatabase and CDaoRecordset for MS Access 2000 Pin
RChin23-Sep-03 10:14
RChin23-Sep-03 10:14 
Generalcreating menus in VC++ dialog application Pin
karteek23-Sep-03 7:39
karteek23-Sep-03 7:39 
GeneralRe: creating menus in VC++ dialog application Pin
David Crow23-Sep-03 8:55
David Crow23-Sep-03 8:55 
QuestionGetClientRect with initial window wrong? Pin
Harco23-Sep-03 6:42
Harco23-Sep-03 6:42 
AnswerRe: GetClientRect with initial window wrong? Pin
cje23-Sep-03 9:00
cje23-Sep-03 9:00 
GeneralMFC ODBC Consumer Wizard Crashes Pin
Matt Gates23-Sep-03 6:22
Matt Gates23-Sep-03 6:22 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.