funtion pow(x,y) problem

This is a discussion on funtion pow(x,y) problem within the C Programming forums, part of the General Programming Boards category; Hi, In my program i use the function pow(16,t) where t is a variable Iside my program i have included ...

  1. #1
    g_p
    g_p is offline
    Registered User
    Join Date
    Dec 2006
    Posts
    85

    funtion pow(x,y) problem

    Hi,

    In my program i use the function pow(16,t) where t is a variable
    Iside my program i have included the libraries

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    #include <math.h>

    When i compile the program i do :

    gcc program.c and i get the output :


    undefined reference to `pow'
    collect2: ld returned 1 exit status


    What shall i do in order this to be compiled?

    Shall i include gcc -sthg program.c ?

  2. #2
    Registered User
    Join Date
    Nov 2006
    Posts
    65
    When I used it a few months ago I located it in the <stdio.h> using the Bloodshed.net ide.
    You rant and rave about it, but at the end of the day, it doesn't matter if people use it as long as you don't see.
    People are free to read the arguments, but if the only way for you to discover gravity is by jumping off a cliff, then that is what you're going to have to experience for yourself.
    Eventually, this "fast and loose" approach of yours will bite you one too many times, then you'll figure out the correct way to do things. - Salem

  3. #3
    g_p
    g_p is offline
    Registered User
    Join Date
    Dec 2006
    Posts
    85
    Well i cannot use Bloodshed.net ide,i have to place sthg next to gcc although i may be wrong

  4. #4
    g_p
    g_p is offline
    Registered User
    Join Date
    Dec 2006
    Posts
    85
    Well i found it,
    It's just that i have to place -lm after the gcc like gcc -lm program.c in order to link the math library

  5. #5
    g_p
    g_p is offline
    Registered User
    Join Date
    Dec 2006
    Posts
    85
    Hi,

    I have an array char buf[100]
    I do:

    gets(buf);
    int x = atoi(&buf[0])

    e.g. i have inserted the number 1234 as a string
    buf now consists of 1234
    buf is like that ->> '1' ,'2','3','4'

    i want the atoi('1') if i do atoi(&buf[0]) returns 1234 as an integer but i want to take only the digit 1 which is in this place not the whole integer

    What shall i do?

  6. #6
    CSharpener vart's Avatar
    Join Date
    Oct 2006
    Location
    Rishon LeZion, Israel
    Posts
    6,424
    1. use fgets(buf, sizeof(buf), stdin) instead of gets
    2. use strtol instead of atoi
    3. to convert 1 char use int digit = myChar-'0';
    The first 90% of a project takes 90% of the time,
    the last 10% takes the other 90% of the time.

  7. #7
    Registered User
    Join Date
    Nov 2006
    Posts
    176
    x = buf[0] - '0';

  8. #8
    g_p
    g_p is offline
    Registered User
    Join Date
    Dec 2006
    Posts
    85
    Thank you all
    I followed your advice and things are better now

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM
  2. Beginner's Problem With First Funtion
    By Ohrange in forum C++ Programming
    Replies: 4
    Last Post: 04-19-2007, 06:59 PM
  3. Laptop Problem
    By Boomba in forum Tech Board
    Replies: 1
    Last Post: 03-07-2006, 05:24 PM
  4. Problem with recursive funtion
    By GaPe in forum C Programming
    Replies: 3
    Last Post: 01-11-2003, 03:32 AM
  5. beginner problem
    By The_Nymph in forum C Programming
    Replies: 4
    Last Post: 03-05-2002, 04:46 PM

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