Page 16 of 21 FirstFirst ... 61415161718 ... LastLast
Results 151 to 160 of 201

Thread: Programming Language

  1. #151
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    That won't compile (you're missing two semicolons), and if it did it would loop infinitely.
    I usually make the semicolon mistakes on every script, and I do realize that scrit wold go on forever and I can easly edit that to -

    void crimeRate(int rate)
    {
    while (rate!=0)
    {
    crimeRate(rate-1);
    }
    }

    int main()
    {
    crimeRate(10);
    }

    Simple as that...

  2. #152
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That'll still loop infinitely. You need to return if rate is less than zero.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #153
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Fine, in that case-

    void crimeRate(int rate)
    {
    if (rate!=0)
    {
    crimeRate(rate-1);
    }
    }

    int main()
    {
    crimeRate(10);
    }

  4. #154
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's more like it. You could also do:
    Code:
    void crimeRate(int rate) {
      if(rate <= 0)
        return;
      crimeRate(rate - 1);
    }
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  5. #155
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Uhhhh, ummm, whats the difference?

  6. #156
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Effectively nothing, but it's neater than wrapping the whole body of the function in a massive if block when you have large amounts of code.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  7. #157
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by djr33 View Post
    Along with encryption comes the dangers of it being broken. The government spends a huge amount of money constantly developing new methods of encryption, so don't think you could code something better.
    NIST has been releasing industrial-grade encryption algorithms for quite some time. There are usually reference implementations available, and one can probably find improved versions by searching on-line.

    At the same time others (and likely the government itself) create complex decryption programs that try to break decryption, so that's out there as well.
    Any encryption algorithm worth anything cannot be defeated by another algorithm. However, governments do have access to supercomputers and clusters that could make short work of relatively weak ciphers by brute force.

    Quote Originally Posted by pcbrainbuster View Post
    Another question that pops in my head is that how do programs when clicked on automatically open other programs that ask for a password before it opens?
    The first program asks the operating system to start a new process. The first program either does the asking, or the second program does (closing immediately if the check fails).

    Also how do certain programs only have one file (itself) and it has songs pictures and all tht being used?
    The data is stored within the executable file, just like with a self-extracting archive.

    Quote Originally Posted by Twey View Post
    Depends. win32 programs have a WINMAIN function instead.
    Windows executables have both a main and a WinMain function. Normally, main is just a stub that would be called when running the program from DOS (not the command line, real DOS) that shows the "This program cannot be run in DOS mode" message and quits. However, that stub can be replaced with code that actually does something useful. When running the program within Windows, the process loader looks for WinMain in preference to main.

    As I recall, the setup program on Windows installation CDs exhibit this duality. The DOS version runs the textual system, useful when installing from scratch, whilst the Windows version takes the graphical approach, usually used when upgrading or repairing an existing installation.

    Quote Originally Posted by pcbrainbuster View Post
    Uhhhh, ummm, whats the difference?
    It's mainly stylistic: the result is still the same (though at an instruction level, an additional ret op-code may be generated if the compiler doesn't think two is excessive).
    Mike

  8. #158
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The data is stored within the executable file, just like with a self-extracting archive.
    How is this done? But I think I know what you mean so the question may be how to do it...

    question-
    1) How do you add bitmaps/images and sound to a console program?

  9. #159
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    In the compilation process, they would simply be embedded.
    I say simply in that I'm sure it isn't difficult, just an option in the compiler.
    How, specially? No real idea.
    But, basically, it's just all written as binary code along with the rest of it and some markers are added so the program knows what bit is what.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #160
    Join Date
    Feb 2007
    Posts
    601
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I actually now remember this guy asking how to do this... But forgot which forum he asked it at...

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •