Thread: Concept

  1. #1
    Registered User
    Join Date
    Jan 2007
    Posts
    12

    Lightbulb Concept

    point of view in a language concept
    manner:

    "Can i say that printf is a command in C language?"

    I think Yes bcos it's a keyword in C and only found in C (i think)

    thnx for the help

  2. #2
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    why do you think it is a keyword?
    Code:
    int main()
    {
    	int printf = 5;
    	return printf;
    }
    It is not.
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  3. #3
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    I wouldn't use the term 'command' or 'keyword' for printf -- I would call it a 'C standard library function' (which was also incorporated into C++).
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  4. #4
    Registered User
    Join Date
    Jan 2007
    Posts
    12
    But how can you set a keyword as a variable name?
    i think I'm lacking some basic knowlage, can anybody give me some good explanation?

  5. #5
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    keyword cannot be used as a variable name. printf is not a keyword.
    it is a function name declared in the stdio.h
    if this header file is not included - this function is not declared. so this name can be used for something else.

    I don't say that it is a good thing to do. But still it is possible to do...
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  6. #6
    Registered User
    Join Date
    Jan 2007
    Posts
    12
    Yeah thanks Got the idea
    thank you

  7. #7
    Just Lurking Dave_Sinkula's Avatar
    Join Date
    Oct 2002
    Posts
    5,005
    7. It is easier to write an incorrect program than understand a correct one.
    40. There are two ways to write error-free programs; only the third one works.*

  8. #8
    Registered User
    Join Date
    Jan 2007
    Posts
    12
    I'm studing programming languages and concepts this year as a subject.

    so in that point of view can i say "printf is a part of C"

    i think it is, even though it is not a keyword, Still it is defiened as function in stdio.h header file.

    any wide comment

    thnx

  9. #9
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    No, it is a part of the Standard C Library, which isn't needed to make a program in C -- Consider the Linux Kernel. . .

  10. #10
    Hurry Slowly vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,788
    as said before
    printf is a C-standard library function.
    it is declared in the stdio.h
    its definition is contained in the c run-time (CRT) library, that should be linked together with the project if some of the functions from this library is used.

    The VC6 for example supplies several versions of this library for release and debug, for sigle and multithreaded project as a static lib or dynamic lib

    Function definition contains its body
    Function declaration - only the prototype used to call it correctly.
    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    – David J. Wheeler

  11. #11
    Registered User
    Join Date
    Jan 2007
    Posts
    12
    Sorry Dumb question

    but anyway it is altogether belongs to C language?

    What defnition do you give to "PART" word in my question?


    thnx
    Last edited by kusal; 01-06-2007 at 12:11 PM.

  12. #12
    {Jaxom,Imriel,Liam}'s Dad Kennedy's Avatar
    Join Date
    Aug 2006
    Location
    Alabama
    Posts
    1,065
    No, printf could be LINKED via another programming language. . . for example Assembly. Therefore it is a PART of the standard C library, in other words a conglomeration of functions needed to do standard things. . . such as I/O, memory management, etc. Long ago, just when C first started, there was no C Library. . . just C. There was a few different I/O libraries out there written in Assembly for C, however, when C first started there was no STANDARD _ANYTHING_. OR. . . no printf.

  13. #13
    Registered User
    Join Date
    Jan 2007
    Posts
    12
    Thnx got the idea

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Question about concept of class
    By Roy01 in forum C++ Programming
    Replies: 6
    Last Post: 11-23-2006, 01:15 AM
  2. Trivial Trigonometry Question, Need Help Understanding Concept
    By SourceCode in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 12-14-2003, 05:50 PM
  3. MUD Concept Question
    By mrpickle in forum Game Programming
    Replies: 3
    Last Post: 12-01-2003, 12:45 PM
  4. help !!concept of class templates
    By sanju in forum C++ Programming
    Replies: 1
    Last Post: 03-20-2003, 09:12 AM
  5. linkedlist concept please!
    By SAMSAM in forum C Programming
    Replies: 3
    Last Post: 03-15-2003, 01:50 PM