Thread: Inputting values into a variable

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    14
    I'm confused why this one works and the other one does not, aren't they both the same?

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    Both Preludes and Laserlights posts are the same. Yours is every so slightly different in that you have the variables BETWEEN the () of main and the { that begins the statements INSIDE the function main - this is where, in the old (original) C style, you'd place the argument types - but you also had to declare those in the () of the function, so:

    Code:
    int main(day, month, year)
    int day, month, year;
    {
    ...
    This would, technically, work, except that the function main is never called with three integer values as arguments. In C++ this would definitely be invalid, and it's on the "undefined" stage of C - so it may work on one system, and not work on another system.

    It is definitely not the right way to do things.

    --
    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.

  3. #3
    Registered User
    Join Date
    Nov 2006
    Location
    japan
    Posts
    126
    Quote Originally Posted by matsp View Post
    Both Preludes and Laserlights posts are the same. Yours is every so slightly different in that you have the variables BETWEEN the () of main and the { that begins the statements INSIDE the function main - this is where, in the old (original) C style, you'd place the argument types - but you also had to declare those in the () of the function, so:

    Code:
    int main(day, month, year)
    int day, month, year;
    {
    ...
    --
    Mats
    It remembered me an old book ...
    Mac OS 10.6 Snow Leopard : Darwin

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Controlling variable values by printing on file
    By p3rry in forum C Programming
    Replies: 8
    Last Post: 12-17-2008, 10:09 AM
  2. Storing int and double type values under one variable name
    By Thanuja91 in forum C++ Programming
    Replies: 10
    Last Post: 10-30-2007, 04:15 AM
  3. Replies: 1
    Last Post: 02-03-2005, 03:33 AM
  4. Problem with a char variable set as a letter
    By 7smurfs in forum C++ Programming
    Replies: 6
    Last Post: 12-10-2004, 01:25 PM
  5. float/double variable storage and precision
    By cjschw in forum C++ Programming
    Replies: 4
    Last Post: 07-28-2003, 06:23 PM