Click here to Skip to main content
15,903,033 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Strange error i cannot fathom Pin
toxcct26-Jul-06 5:09
toxcct26-Jul-06 5:09 
AnswerRe: Strange error i cannot fathom Pin
Zac Howland26-Jul-06 5:03
Zac Howland26-Jul-06 5:03 
Questionconversion Pin
RockyJames26-Jul-06 4:32
RockyJames26-Jul-06 4:32 
AnswerRe: conversion Pin
David Crow26-Jul-06 4:45
David Crow26-Jul-06 4:45 
GeneralRe: conversion Pin
RockyJames26-Jul-06 4:53
RockyJames26-Jul-06 4:53 
QuestionRe: conversion Pin
David Crow26-Jul-06 5:03
David Crow26-Jul-06 5:03 
AnswerRe: conversion Pin
toxcct26-Jul-06 5:05
toxcct26-Jul-06 5:05 
AnswerRe: conversion Pin
Zac Howland26-Jul-06 5:13
Zac Howland26-Jul-06 5:13 
RockyJames wrote:
i have funtion named change(long lngNo,unsigned char* pData);

where some times i send intger data,float data ,BOOL data as second parameter.How do i convert integer ,float ,BOOL to unsigned char*.


It is very bad practice to write a one-size-fits-all function. If you are trying to do something with the bytes (i.e. send them across a network using sockets), that is one thing, but if you are trying to decrease the number of methods you need to write for a given operation that doesn't involve direct byte transmissions, then this is the wrong approach.

A cleaner way of doing it would be to:

typedef unsigned long ulong;
typedef unsigned char byte;
// hide this method so that it isn't exposed
void change(ulong size, byte* data)
{
	// do something with data
}

// this is the exposed method
template<class T> void change(const T& data)
{
	change(sizeof(T), (byte*)&data);
}


If you decide to become a software engineer, you are signing up to have a 1/2" piece of silicon tell you exactly how stupid you really are for 8 hours a day, 5 days a week

Zac

GeneralRe: conversion Pin
RockyJames26-Jul-06 16:00
RockyJames26-Jul-06 16:00 
GeneralRe: conversion Pin
Zac Howland26-Jul-06 19:14
Zac Howland26-Jul-06 19:14 
QuestionIn C++, how get the value and key in the IDictionary Pin
chenxiujie26-Jul-06 4:19
chenxiujie26-Jul-06 4:19 
QuestionRe: In C++, how get the value and key in the IDictionary Pin
David Crow26-Jul-06 4:33
David Crow26-Jul-06 4:33 
QuestionStart a powerpoint slideshow from C++ (.pps file) Pin
Remco Hoogenboezem26-Jul-06 3:54
Remco Hoogenboezem26-Jul-06 3:54 
AnswerRe: Start a powerpoint slideshow from C++ (.pps file) Pin
David Crow26-Jul-06 3:59
David Crow26-Jul-06 3:59 
AnswerRe: Start a powerpoint slideshow from C++ (.pps file) Pin
Hamid_RT26-Jul-06 5:24
Hamid_RT26-Jul-06 5:24 
QuestionIncluding an SDI in a Dialog based project Pin
cv_k3n26-Jul-06 3:41
cv_k3n26-Jul-06 3:41 
AnswerRe: Including an SDI in a Dialog based project Pin
Cedric Moonen26-Jul-06 3:44
Cedric Moonen26-Jul-06 3:44 
GeneralRe: Including an SDI in a Dialog based project Pin
cv_k3n26-Jul-06 3:55
cv_k3n26-Jul-06 3:55 
GeneralRe: Including an SDI in a Dialog based project Pin
Cedric Moonen26-Jul-06 4:01
Cedric Moonen26-Jul-06 4:01 
GeneralRe: Including an SDI in a Dialog based project Pin
Zac Howland26-Jul-06 4:10
Zac Howland26-Jul-06 4:10 
Questiondll hooking Pin
TusharKavali26-Jul-06 2:23
TusharKavali26-Jul-06 2:23 
AnswerRe: dll hooking Pin
_AnsHUMAN_ 26-Jul-06 2:28
_AnsHUMAN_ 26-Jul-06 2:28 
AnswerRe: dll hooking Pin
Hamid_RT26-Jul-06 2:36
Hamid_RT26-Jul-06 2:36 
QuestionHooking Pin
TusharKavali26-Jul-06 2:21
TusharKavali26-Jul-06 2:21 
AnswerRe: Hooking Pin
sudeesh26-Jul-06 2:32
sudeesh26-Jul-06 2:32 

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.