Thread: 2^16 (65536) chars

  1. #1
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Cool 2^16 (65536) chars

    Hi!

    I just want to ask you guys if there is a possibility to write 2^16 (65536) different characters into a file?

    Thank you in advance for your answers,
    Gašper.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  2. #2
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    why wouldn't it be?

  3. #3
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    If it is possible than tell me how ?

    I would really love to see an example (c program).
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  4. #4
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    char buff[65536];
    fwrite ( buff, sizeof(buff), 1, fp );

    Of course, if you're using crummy 16 bit DOS, then you can't do this....
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  5. #5
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,227
    ...and don't forget to use fopen and fclose...

  6. #6
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669

    Talking

    Salem:

    I'm using 16 Bit DOS compiler (TURBO C++ 3.0). Where could I find the newest compiler that will support 65536 different characters?

    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  7. #7
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    http://www.compilers.net/ has a selection

    DJGPP is perhaps the most DOS-like - though it is a 32 bit compiler.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  8. #8
    Registered User
    Join Date
    Aug 2001
    Posts
    207
    I've just downloaded from here:

    http://www.cprogramming.com/borland.html

  9. #9
    Registered User
    Join Date
    Sep 2001
    Posts
    13

    SAMPLE

    it looks like you are trying to write binary, if so here is a sample from a project that i've just completed. select code copy paste and try it. this is in DEV-C++


    int main()
    {
    short Decimal, Octal, Hexadecimal;
    int Stop = 0, temp, Binary;
    char Continue[16];
    Decimal = 0;

    do
    {
    Stop = Decimal + 16; // stops after a display of 0-15 prompt to continue
    printf("Decimal\t\tBinary\t\t\t0ctal\t\tHexadecima l\t\n");
    printf("\n");

    do
    {
    printf("%d\t\t", Decimal);
    temp = Decimal;
    for (Binary = 128; Binary > 0; Binary /= 2)

    {
    if (temp >= Binary)
    {
    printf("1");
    temp -= Binary;
    }
    else
    printf("0");

    if (Binary == 16)
    printf(" ");
    }
    temp = Octal;
    printf("\t\t%o\t\t%hx\n", Decimal, Decimal);
    Decimal++;

    }
    while (Decimal < Stop );

    printf("\nTo Continue press enter, (N) to end : ");
    fgets(Continue,16,stdin);
    }
    while (!strstr(Continue,"n")&& !strstr(Continue,"N"));


    return 0;

    }

  10. #10
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    folks!

    Example of my program:

    for (i=0; i<=65535; i++)
    {
    fprintf(fout, "%c", i);
    }

    Now, my compiler writes only 256 different characters (ASCII Table), but I want that it will write into file 2^16 different characters.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  11. #11
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    You are confused.

    A 'char' is only 8 bits, thus, you have a maximum of 256 values.
    A 'short int' is 16 bits.

    Thus, if you read a single byte, you will only ever get one of 256 different values. If you want more, read or write more than a byte at a time.

    Quzah.
    Hope is the first step on the road to disappointment.

  12. #12
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    phew... i thought salem's wisdom had an end for a second there... especially over something that's a fundamental truth... yes it's a matter of reading/writing... hmmm... i have heard of unicode 16 bit characters... but don't know the specifics of it...

    oh wait, he means since you can't get the whole segment... ::is enlightened to truth::...

    my oh my...
    hasafraggin shizigishin oppashigger...

  13. #13
    Sayeh
    Guest
    Turn the computer off. Take it back to the store. You are more suited towards other interests and lines of work.

    Sorry, but not everybody can, or even should, be near a computer.

  14. #14
    Linguistic Engineer... doubleanti's Avatar
    Join Date
    Aug 2001
    Location
    CA
    Posts
    2,459
    who was that directed at? if that was directed at me... you do remember me from the old board right sayeh? if there is a problem, confront...
    hasafraggin shizigishin oppashigger...

  15. #15
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,661
    > phew... i thought salem's wisdom had an end for a second there
    Must be time for some deliberate mistakes then, to see who's awake
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. while condition question..
    By transgalactic2 in forum C Programming
    Replies: 3
    Last Post: 04-04-2009, 04:49 PM
  2. Counting how many chars in a string
    By tigs in forum C Programming
    Replies: 4
    Last Post: 08-05-2002, 12:25 AM
  3. really got stuck with unsigned chars
    By Abdi in forum C Programming
    Replies: 7
    Last Post: 06-11-2002, 12:47 PM
  4. move chars position
    By SpuRky in forum C Programming
    Replies: 3
    Last Post: 06-09-2002, 02:59 AM
  5. fancy strcpy
    By heat511 in forum C++ Programming
    Replies: 34
    Last Post: 05-01-2002, 04:29 PM