Thread: C in general

  1. #1
    Registered User
    Join Date
    Feb 2005
    Posts
    30

    C in general

    hi all

    sorry I couldn't find a precise title..
    I'm new to C I usually write in JAVA or Visual basics 6, so there are a few things I want to ask you about, I know some questions might seem silly:

    1- suppose you have the string "2004004", how can you convert this to a "long" value? in general is there a way in C to convert from Strings to int or long or double?

    2-when reading for a txt file, I used the following code:

    fscanf(fileName," %s %s %s ", nm, fm, un);
    //nm fm and un are string variables so no problem here

    if I do this iteratively shouldn't I get the next lines in the file until the feof?

    3-I went over the basics in C but I didn't read anything concerning graphics...Is there a way to create GUIs in C? if so can you point me to an online tutorial?

    4- and also about random number: how do we generate random numbers?


    thanks

  2. #2
    Gawking at stupidity
    Join Date
    Jul 2004
    Location
    Oregon, USA
    Posts
    3,218
    You can use strtol() to convert from string to long, and you can use strtod() to convert from string to double.
    If you understand what you're doing, you're not learning anything.

  3. #3
    Registered User
    Join Date
    Feb 2005
    Posts
    30
    that's weird...I have the string.h library in front of me but I couldn't find these functions

    thanks a lot

  4. #4
    Registered User
    Join Date
    Mar 2004
    Posts
    536
    Quote Originally Posted by majoub
    that's weird...I have the string.h library in front of me but I couldn't find these functions

    thanks a lot

    Check <stdlib.h>

    Regards,

    Dave

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. General programming
    By gin in forum Tech Board
    Replies: 39
    Last Post: 07-14-2008, 10:37 AM
  2. General Guidelines on Preventing Header File collision
    By stanlvw in forum C++ Programming
    Replies: 12
    Last Post: 07-05-2008, 04:02 AM
  3. Password program / general programming questions
    By plr112387 in forum C++ Programming
    Replies: 13
    Last Post: 11-04-2007, 10:10 PM
  4. General Trees, calculating height
    By neandrake in forum C++ Programming
    Replies: 3
    Last Post: 04-08-2005, 08:59 AM
  5. General Protection Exception
    By s9uare in forum C++ Programming
    Replies: 1
    Last Post: 11-02-2002, 10:46 AM