Thread: Explanation of a function.

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    what's the command prompt? what's the difference between the command prompt to the command line?
    what's the console?
    somefile and someoutfile? what are these? :O

    why did he type (ch=getchar()) != '\n'?
    Last edited by eXeCuTeR; 11-26-2007 at 04:29 AM.

  2. #2
    C++ Witch laserlight's Avatar
    Join Date
    Oct 2003
    Location
    Singapore
    Posts
    28,413
    Oh dear. You have only ever done GUI programming? I thought most people start off programming for the command line/prompt.

    Say I ask you to write a "hello world" program. What would you write?
    Quote Originally Posted by Bjarne Stroustrup (2000-10-14)
    I get maybe two dozen requests for help with some sort of programming or design problem every day. Most have more sense than to send me hundreds of lines of code. If they do, I ask them to find the smallest example that exhibits the problem and send me that. Mostly, they then find the error themselves. "Finding the smallest program that demonstrates the error" is a powerful debugging tool.
    Look up a C++ Reference and learn How To Ask Questions The Smart Way

  3. #3
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    #include <stdio.h> int main(void) { printf("hello world"); return 0; }
    what's the point?

  4. #4
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    No newlines?

    The point I think Laserlight is making is that console programming is the "basic level", if you are not familiar with command prompts and console programs, perhaps you are missing a big part of the knowledge necessary for generic programming.

    By the way, stdout and stdin is part of what you get from "stdio.h".

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  5. #5
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Console programming and command prompts is when this DOS window comes when you compile it, isn't it? Well, here in Linux it's not exactly a DOS window, but it still looks like it.

  6. #6
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by eXeCuTeR View Post
    Console programming and command prompts is when this DOS window comes when you compile it, isn't it? Well, here in Linux it's not exactly a DOS window, but it still looks like it.
    Yes, that's it. Allthough technically, it hasn't been a "DOS box" since Windows 3.1 - it can BECOME a DOS-box if you run a 16-bit application, and most people call it a DOS box even when it's running a 32-bit native Windows application. And of course, your Linux/Unix xterm or whatever isn't ever a DOS-box, but serves the same purpose of "typing commands and executing them", which is what it's all about.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  7. #7
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Is there any other "style" or however you call it, than the console in C?

  8. #8
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by eXeCuTeR View Post
    Is there any other "style" or however you call it, than the console in C?
    Yes, that would be "graphical user interface" programming, which doesn't, normally, use stdin and stdout.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  9. #9
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    How do I use this GUI programming?

  10. #10
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by eXeCuTeR View Post
    How do I use this GUI programming?
    The actual programming is no different - you still write code, but for example you may call "CreateWindow()" to create a window that you then draw some text using "TextOut", etc. [that's Windows API - The Xwindows standard is similar but also different].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  11. #11
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Sounds familiar from C#.
    But how could I program in Linux with windows forms and stuff? will it still work? or I should download windows.h and put it somewhere (where?) so it can work.
    Last edited by eXeCuTeR; 11-26-2007 at 07:38 AM.

  12. #12
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Quote Originally Posted by eXeCuTeR View Post
    Sounds familiar from C#.
    But how could I program in Linux with windows forms and stuff? will it still work? or I should download windows.h and put it somewhere (where?) so it can work.
    No, not at all the same API, and windows.h is just a set of declarations of functions and data structures for the Windows API. There are "multi-target" libraries, e.g. wxWidgets() that can be used for Linux and Windows and others, but the native API is diffferent.

    For now, I suggest you ignore ALL of the GUI programming and concentrate on learning the language itself.

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  13. #13
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Quote Originally Posted by matsp View Post
    No, not at all the same API, and windows.h is just a set of declarations of functions and data structures for the Windows API. There are "multi-target" libraries, e.g. wxWidgets() that can be used for Linux and Windows and others, but the native API is diffferent.

    For now, I suggest you ignore ALL of the GUI programming and concentrate on learning the language itself.

    --
    Mats
    Ok, was just wondering.

    I'm still looking for a great tutorial I could learn from.
    I've read plenty (actually, A LOT) tutorials on the net, and I can't find one that supplies all the answers to all of my questions (well, that's a little extremist but you know what I am).
    Any suggestions?

  14. #14
    Registered User
    Join Date
    Oct 2001
    Posts
    2,129

  15. #15
    Registered User
    Join Date
    Oct 2007
    Posts
    242
    Quote Originally Posted by robwhit View Post
    I've read it already, it doesn't really fits the tutorial I'm seeking.
    What about C Primer Plus, Fifth Edition? is this a good one? of course I'm gonna read the 4-6 last chapters, I know the basic stuff in there already.
    Last edited by eXeCuTeR; 11-27-2007 at 03:37 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Undefined Reference Compiling Error
    By AlakaAlaki in forum C++ Programming
    Replies: 1
    Last Post: 06-27-2008, 11:45 AM
  2. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  3. We Got _DEBUG Errors
    By Tonto in forum Windows Programming
    Replies: 5
    Last Post: 12-22-2006, 05:45 PM
  4. Replies: 18
    Last Post: 12-31-2005, 01:56 PM
  5. Question..
    By pode in forum Windows Programming
    Replies: 12
    Last Post: 12-19-2004, 07:05 PM