I thought I understood this.

This is a discussion on I thought I understood this. within the C Programming forums, part of the General Programming Boards category; Im taking in some command line arguments, they are floats. how come this doesnt work? float tol = atof(argv[2]); printf("%f ...

  1. #1
    Registered User
    Join Date
    Dec 2009
    Posts
    41

    I thought I understood this.

    Im taking in some command line arguments, they are floats. how come this doesnt work?

    float tol = atof(argv[2]);

    printf("%f Tol:\n",tol);

    it prints a very large number, im assuming the mem location.


    any help is greatly appreciated, I have tried it with sscanf to no avail as well.

    this is in c, compiled in unix with gcc.

  2. #2
    Registered User
    Join Date
    Sep 2004
    Location
    California
    Posts
    3,265
    Make sure you are including stdlib.h in your program.
    bit∙hub [bit-huhb] n. A source and destination for information.

  3. #3
    cas
    cas is offline
    Registered User
    Join Date
    Sep 2007
    Posts
    993
    Since you're using gcc, you should always build with the -Wall flag. That would have pointed you in the direction of a missing stdlib.h (which does indeed sound like the problem). -Wall will enable more warnings, and when you get a warning, you should fix it.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. random encryption thought
    By ggs in forum A Brief History of Cprogramming.com
    Replies: 2
    Last Post: 03-12-2002, 09:32 PM
  2. Won't Return pointer, i can't find why...
    By ss3x in forum C++ Programming
    Replies: 2
    Last Post: 02-28-2002, 08:50 PM
  3. Variable Argument Functions
    By genghis in forum C++ Programming
    Replies: 6
    Last Post: 02-10-2002, 02:01 PM
  4. Interesting Thought....
    By DavidP in forum A Brief History of Cprogramming.com
    Replies: 3
    Last Post: 11-02-2001, 06:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21