Click here to Skip to main content
15,891,809 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: interact between 2 process - urgent!!!! Pin
Luc Pattyn17-Jan-09 7:34
sitebuilderLuc Pattyn17-Jan-09 7:34 
GeneralRe: interact between 2 process - urgent!!!! Pin
CPallini17-Jan-09 9:22
mveCPallini17-Jan-09 9:22 
GeneralRe: interact between 2 process - urgent!!!! Pin
Luc Pattyn17-Jan-09 9:32
sitebuilderLuc Pattyn17-Jan-09 9:32 
GeneralRe: interact between 2 process - urgent!!!! Pin
CPallini17-Jan-09 9:43
mveCPallini17-Jan-09 9:43 
GeneralRe: interact between 2 process - urgent!!!! Pin
Luc Pattyn17-Jan-09 9:55
sitebuilderLuc Pattyn17-Jan-09 9:55 
GeneralRe: interact between 2 process - urgent!!!! Pin
Luc Pattyn17-Jan-09 9:57
sitebuilderLuc Pattyn17-Jan-09 9:57 
JokeRe: interact between 2 process - urgent!!!! Pin
CPallini17-Jan-09 22:30
mveCPallini17-Jan-09 22:30 
QuestionProblem with record reading from a binary file Pin
Umer Aziz17-Jan-09 1:05
Umer Aziz17-Jan-09 1:05 
I have compiled the following program in MS Visual C++ 6.0
Its strange for me to know the output of the program.

#include <stdio.h>

struct struct1
{
int i;
};


struct struct2
{
char s[2];
};

struct struct3
{
char s[2];
int i;
};


struct struct4
{
char s1[2];
int i;
char s2[2];
};

struct struct5
{
int i;
char s2[2];
};


int main()
{
printf("\nSize of Structure 1 = %d",sizeof(struct struct1));
printf("\nSize of Structure 2 = %d",sizeof(struct struct2));
printf("\nSize of Structure 3 = %d",sizeof(struct struct3));
printf("\nSize of Structure 4 = %d",sizeof(struct struct4));
printf("\nSize of Structure 5 = %d",sizeof(struct struct5));

printf("\n\n");

return 0;
}



The size shown by the program for structure 1 and 2 is OK. But result of structure 3,4 and 5 is mind f***ing. Why; when I declare the integer and charector in the same structer, the compiler add 2 extra bytes?

Actually i am reading the data from a binary file using the structure. But this thing has made me fool from last 2
days.

If anyone knows the reason or solution of that problem, please reply.

----------------------Output of the program-----------------
Size of Structure 1 = 4
Size of Structure 2 = 2
Size of Structure 3 = 8
Size of Structure 4 = 12
Size of Structure 5 = 8
AnswerRe: Problem with record reading from a binary file Pin
Garth J Lancaster17-Jan-09 1:10
professionalGarth J Lancaster17-Jan-09 1:10 
AnswerRe: Problem with record reading from a binary file Pin
Stuart Dootson17-Jan-09 1:16
professionalStuart Dootson17-Jan-09 1:16 
GeneralRe: Problem with record reading from a binary file Pin
Luc Pattyn17-Jan-09 4:24
sitebuilderLuc Pattyn17-Jan-09 4:24 
AnswerRe: Problem with record reading from a binary file Pin
Umer Aziz17-Jan-09 18:21
Umer Aziz17-Jan-09 18:21 
QuestionBlum-Blum-Shub Pin
RomTibi17-Jan-09 0:04
RomTibi17-Jan-09 0:04 
AnswerRe: Blum-Blum-Shub Pin
Garth J Lancaster17-Jan-09 0:30
professionalGarth J Lancaster17-Jan-09 0:30 
GeneralRe: Blum-Blum-Shub Pin
RomTibi17-Jan-09 2:55
RomTibi17-Jan-09 2:55 
GeneralRe: Blum-Blum-Shub Pin
Garth J Lancaster17-Jan-09 15:39
professionalGarth J Lancaster17-Jan-09 15:39 
GeneralRe: Blum-Blum-Shub Pin
RomTibi17-Jan-09 22:39
RomTibi17-Jan-09 22:39 
GeneralRe: Blum-Blum-Shub Pin
RomTibi18-Jan-09 7:55
RomTibi18-Jan-09 7:55 
JokeYaba-daba-du! Pin
CPallini17-Jan-09 5:08
mveCPallini17-Jan-09 5:08 
GeneralRe: Yaba-daba-du! Pin
Garth J Lancaster17-Jan-09 15:28
professionalGarth J Lancaster17-Jan-09 15:28 
GeneralRe: Yaba-daba-du! Pin
RomTibi17-Jan-09 22:42
RomTibi17-Jan-09 22:42 
GeneralRe: Yaba-daba-du! Pin
RomTibi17-Jan-09 22:41
RomTibi17-Jan-09 22:41 
GeneralRe: Yaba-daba-du! Pin
ThatsAlok18-Jan-09 18:15
ThatsAlok18-Jan-09 18:15 
GeneralRe: Yaba-daba-du! Pin
RomTibi21-Jan-09 7:52
RomTibi21-Jan-09 7:52 
Questionmultithread Pin
RomTibi17-Jan-09 0:02
RomTibi17-Jan-09 0:02 

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.