In case of
item/4 you get result 0 for item 0-3 and result 1 for item 4-7. In case of
item%2 you get result 0 for item 0,2,4,6 and result 1 for item 1,3,5,7. Therefore final output is different...
Type: Posts; User: nenpa8lo
In case of
item/4 you get result 0 for item 0-3 and result 1 for item 4-7. In case of
item%2 you get result 0 for item 0,2,4,6 and result 1 for item 1,3,5,7. Therefore final output is different...
scanf() did the job, thanks.
Hi,
I'm expecting a very long input like up to 1000 values each as big as 1to100 (1 55 100 34 44 etc.). This is how I do it:
char buffer[4 * 1000];
char *ptr;
char val;
int i;
scanf("%s",...
I'll go for an integer solution. Easy, reliable and most likely faster.
Maybe I'll tell you what I want to do. I want to design a system return type. By that I mean a data type that would be used in the system (in some of the system functions). I came up with this...
Which one is faster (and why). Returning structure:
struct
{
unsigned char foo1;
unsigned char foo2;
} or returning unsigned int. Lets assume that they both take 16bits. Which one will be faster?
Ok I agree with what you said.
I'm not sure about this one. In embedded you usually create cstartup file which is written in assembly and it has section that describe which part of SRAM data...
I recently met following statement:
void func(void)
{
const unsigned char *const tab[]=
{
"Str1",
"Str2",
"Str3"
};
/* some code...
Does anyone have an experience in creating own library in IAR environment? All I have is xlib.exe and it says that i should specify module to be a library by
xlib m-l module_to_be_library.rnnwhere...
Compiler is IAR for Embedded systems.
From the manual:
The printf and sprintf functions use a common formatter called
_formatted_write. The ANSI standard version of _formatted_write
is very...
so what's the real value of ShiftedBit?
Bit representation is:
0x00008000 => 0000 0000 0000 0000 1000 0000 0000 0000So if I compare this then
unsigned long int OtherBit = 1;
unsigned long...
I've found that 1 << 31 gives 'long' (-2147483648) instead of 'unsigned long'. Is that correct?
Works now. Legend
Hi,
long unsigned int ShiftedBit = 0;
ShiftedBit = 1 << 15;
printf("%ld", ShiftedBit);Gives me a value of -32768. Code is written on 16 bit machine so unsigned int is 16bit and long...
See I tought that I can maybe mess around in cstartup file. It has code to set whole stuff for OS. So if at the beginning of file I do in asm:
org 0
--define me 2B--
then that would work? Don't...
Simply main does not see 'ptr' and also it exists only for while when test() is called.
Sorry, but I misstyped. I mean how can i force a compiler to build a value in ROM at address I want. I think that this must be done at compiling/linking stage. I need this to embedded system.
...
Hi guys,
Just wondering is it possible to force compiler to place a constant at some specific address?
Hi All,
Do you know why software should have only one exit from any function regarding to IEC 61508? Because it takes long way/code to get out from very 'deep code' to the end of the function and...
And another one.
WORD data;
data = 0xE9E9;
data >>= 8; is it always true that bits on the left hand side are '0' ? And in this case final value is 0x00E9? What if I want 3th byte from long (4B)? ...
So what you recommend for good coding practice? Which casting is better (safer, faster etc.)?
Hi All,
Is there any difference?
unsigned char data;
unsigned int worddata;
data = (unsigned char)worddata; and
data = (unsigned char)(0x00FF & worddata);
Correct me if I'm wrong. When I do myfile.out < file.txt, file.txt is read in myfile.out as an keyboard, therefore I can not look for EOF. However I think that while(getc()) will work.
Simply in Linux you can use ReadDataFromKB.out < file.txt
And I want to handle what ever is in the file.txt. Data must be process till NULL character.
input is STDIO (keyboard) :(