Jump to content
Sign in to follow this  
sch

sizeof not working?

Recommended Posts

Hello,

 

I tried

 

 

void sizes()
{
char buff[256];

sprintf(buff,"sizeof(char)=%d\n",sizeof(char));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(short int)=%d\n",sizeof(short int));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(int)=%d\n",sizeof(int));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(long int)=%d\n",sizeof(long int));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(long long int)=%d\n",sizeof(long long int));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(float)=%d\n",sizeof(float));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(double)=%d\n",sizeof(double));
SCI_putStr(mySci,buff);
}

 

On my serial terminal I see

 

sizeof(char)=0

sizeof(short int)=0

sizeof(int)=0

sizeof(long int)=0

sizeof(long long int)=0

sizeof(float)=0

sizeof(double)=0

 

what can be wrong? :)

Share this post


Link to post
Share on other sites

Hello,

 

I tried

 

 

void sizes()
{
char buff[256];

sprintf(buff,"sizeof(char)=%d\n",sizeof(char));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(short int)=%d\n",sizeof(short int));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(int)=%d\n",sizeof(int));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(long int)=%d\n",sizeof(long int));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(long long int)=%d\n",sizeof(long long int));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(float)=%d\n",sizeof(float));
SCI_putStr(mySci,buff);

sprintf(buff,"sizeof(double)=%d\n",sizeof(double));
SCI_putStr(mySci,buff);
}

 

On my serial terminal I see

 

sizeof(char)=0

sizeof(short int)=0

sizeof(int)=0

sizeof(long int)=0

sizeof(long long int)=0

sizeof(float)=0

sizeof(double)=0

 

what can be wrong? :)

Use %ld

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...