>I am using turbo c 2.01. I would expect this to printf 1010101 but
>it wont I have tried several different things, mostly with include
>files and data types of combined_data. It works when compiled with
>Dev-cpp but I need it for a 16 bit target system.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>Any help and comment are appreciated.
[code omitted]
One thing you omitted from your original post was what the output was on
your 16 bit system! (Just saying 'it's wrong' isn't sufficient for us to
make an intelligble guess at the problem)
Now - on making a few assumptions....
Assumption 1:
You need an unsigned long, not a normal 'long' - change line 7 of your
code.
Assumption 2: You compiler is non-conforming:
Ignoring the " for include files, and the typo in assignment, you
clearly need a datatype that is 32 bits wide if you want to store 4 (8
bit) bytes in it. Now according to The Standard, type 'long' should
suffice (32 bits minimum from the value of LONG_MAX.) Either your
compiler isn't conforming or there's somenthing you're not telling us.
On your 16 bit system copy/paste the following code and paste, back to
the group, the output - either compile errors if any, or the output if
not (output on my 32bit box included):
$ type test.c
#include <stdio.h>
#include <limits.h>
int main(void){
unsigned long x = ULONG_MAX;
int y=0;
printf("CHAR_BIT = %d\n", CHAR_BIT);
printf("uLONG_MAX = %lu\n", x);
while (x=x<<1) y++;
printf("bits per ULONG_MAX = %d\n", y);
return 0;
}
$ testc
CHAR_BIT = 8
uLONG_MAX = 4294967295
bits per ULONG_MAX = 31
$
--
PJH
"Consistently separating words by spaces became a general custom about
the tenth century A.D., and lasted until about 1957, when FORTRAN
abandoned the practice." -- Sun FORTRAN Reference Manual
Alderley plc, Arnolds Field Estate, The Downs, Wickwar, Gloucestershire, GL12 8JD, UK
Tel: +44(0)1454 294556 Fax: +44 (0)1454 299272
Website : www.alderley.com Sales : [EMAIL PROTECTED] Service : [EMAIL PROTECTED]
This email and its contents are confidential and are solely for the use of the intended recipient. If you are not the original recipient you have received it in error and any use, dissemination, forwarding, printing or copying of this email is strictly prohibited. Should you receive this email in error please immediately notify [EMAIL PROTECTED]
This email has been scanned for viruses, however you should always scan emails with your own systems prior to opening.
To unsubscribe, send a blank message to <mailto:[EMAIL PROTECTED]>.
| Yahoo! Groups Sponsor | |
|
|
Yahoo! Groups Links
- To visit your group on the web, go to:
http://groups.yahoo.com/group/c-prog/
- To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
- Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
