<?
#include <stdio.h> 
#include <stdlib.h> 

float numberArray[5]; // to hold the values 


// A funtion to ask for a float 
void readFloat(int num


float tnum
char line[256]; 


printf("\nEnter Value %i : ",num); // Ask 
getline(line256); // read 
tnum = (float)strtod(line); // convert (0 if invalid) 

if (tnum == 0

printf("\nInvalid Input... try again); 
readFloat(num); // loop 

else 
numberArray[num] = tnum; // store one value 




// Display the array 
void displayAll() 

for(int i = 0; i < 5; i++) 
printf("
\nTemp %= %f",i,numberArray[i]); 




// Selection Sort 
void sortArray() 



int i,j,n,min_pos; 
float tmp; 

for (i=1; i < n; i++)

min_pos = i; 
for (j = i + 1; j < n; j++) 
if (numberArray[j] < numberArray[min_pos]) min_pos = j;

tmp = numberArray[i]; 
numberArray[i] = numberArray[min_pos]; 
numberArray[min_pos] = tmp; 





void convToCelcius() 



for(int i = 0; i < 5; i++) 
numberArray[i] = ( ( (numberArray[i] - 32) / 9) * 5 ); 




void convToFahr() { 

for(int i = 0; i < 5; i++) 
numberArray[i] = ( (numberArray[i]/5) * 9) + 32; 




void main() 



for(int i = 0; i < 5; i++) 
readFloat(i); 


printf("
\nHere are the numbers entered ") 
sortArray(); 
displayAll(); 

char c; 
printf("
Convert to Farheniet?"); 

scanf("
%c",&c); 

if(c = 'Y') 

convToFahr(); 

printf("
\nHere are the converted numbers"); 
displayAll(); 
char c2; 
printf("
Convert back?"); 
scanf("
%c",&c2); 
if(c2 = 'Y') 

convToCelcius(); 
printf("
\nHere are your numbers"); 
displayAll(); 


}
?>
<?
printf
("\nEnter Value %i : ",num); // Ask 
getline(line256); // read 
tnum = (float)strtod(line); // convert (0 if invalid)
?>
C programming - TranceAddict Forums - Chill Out Room
return to tranceaddict TranceAddict Forums Archive > Main Forums > Chill Out Room

Pages: [1] 2 
C programming
View this Thread in Original format
Michael19
alright nerd. i need your help.


PHP:



i keep getting an error saying " undefined function 'getline'" and "too few parameters in call to strtod"

there a few other ty little problems like no ; at the end of some of the words, but thats fine.
Michael19
it was typed in notepad :rolleyes: :D
Michael19
quote:
Originally posted by Nou
wtf... half this code isnt even correct...


seriously, your gettin syntax errors left and right, I would fix those before worrying about thos function calls getting messed up.

$10 says fixing those syntax errors will also solve your other problems!



i fixed the syntax errors before and it didnt help, its definitly the function call problems. i will finish the syntax erors for you now though.
Michael19
i fixed all the syntax errors in the original post now i think.
RenderedDream
quote:
Originally posted by Michael19
i fixed all the syntax errors in the original post now i think.


wtf's this then?

quote:
for (i=1; i

{

min_pos = i;

for (j=i+1; j
Michael19
for (i=1; i < n; i++)
{
min_pos = i;
for (j=i+1; j < n; j++)




is that right?:conf: i cant notice the mistake if your post in the original one.

i aint be doing this very long so that why its e. :stongue:

when i go to edit it, its fine, but it doesnt look fine when posted, n piece of
Michael19
there
Resnick
so where is this getline function actually defined? u gotta include it at the top of ur code (unless its standard built in functino of c, but make sure ur including the right files, and using right parameters/syntax to call the function)
Michael19
quote:
Originally posted by Resnick
so where is this getline function actually defined? u gotta include it at the top of ur code (unless its standard built in functino of c, but make sure ur including the right files, and using right parameters/syntax to call the function)


spot on, cheers
Michael19
PHP:





second problem is " too few parameters in call to strtod(const char*, char**0"


any ideas anyone?:conf:

Resnick
double strtod(const char *nptr, char **endptr);

im not even sure if thats what ur talking about..but google says theres two parameters :P

edit: and in fact thats what the compiler error told u...ur only giving it one parameter in the code u quoted
Michael19
quote:
Originally posted by Resnick
double strtod(const char *nptr, char **endptr);

im not even sure if thats what ur talking about..but google says theres two parameters :P

edit: and in fact thats what the compiler error told u...ur only giving it one parameter in the code u quoted


i am now getting an expression syntax instead :conf:
CLICK TO RETURN TO TOP OF PAGE
Pages: [1] 2 
Privacy Statement