-
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 ?
-
When I used it a few months ago I located it in the <stdio.h> using the Bloodshed.net ide.
-
Well i cannot use Bloodshed.net ide,i have to place sthg next to gcc although i may be wrong
-
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 :)
-
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?
-
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';
-
-
Thank you all:)
I followed your advice and things are better now :)