<?
#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

Become a part of the TranceAddict community!Frequently Asked Questions - Please read this if you haven'tSearch the forums
TranceAddict Forums > Main Forums > Chill Out Room > C programming
Pages (2): [1] 2 »   Last Thread   Next Thread
Share
Author
Thread    Post A Reply
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire
C programming

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 shitty little problems like no ; at the end of some of the words, but thats fine.


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Last edited by Michael19 on Feb-24-2005 at 03:08

Old Post Feb-23-2005 23:24 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire

it was typed in notepad


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Old Post Feb-23-2005 23:38 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire

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.


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Old Post Feb-23-2005 23:47 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire

i fixed all the syntax errors in the original post now i think.


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Old Post Feb-23-2005 23:49 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message
RenderedDream
what should i put here?



Registered: Dec 2001
Location: Aveiro

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


___________________
INTERNET'S COOLSTUFF NEWSPAPER Funstuff Blog!

Old Post Feb-24-2005 01:06  Portugal
Click Here to See the Profile for RenderedDream Click here to Send RenderedDream a Private Message Visit RenderedDream's homepage! Add RenderedDream to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire

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




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

i aint be doing this very long so that why its shite.

when i go to edit it, its fine, but it doesnt look fine when posted, fuckn piece of shit


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Last edited by Michael19 on Feb-24-2005 at 01:18

Old Post Feb-24-2005 01:12 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire

there


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Old Post Feb-24-2005 03:09 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Resnick
Supreme tranceaddict



Registered: Feb 2003
Location: Toronto

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)


___________________
it was the greatest feeling of nothingness i have ever experienced...

Old Post Feb-24-2005 03:13  Canada
Click Here to See the Profile for Resnick Click here to Send Resnick a Private Message Add Resnick to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire

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


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Old Post Feb-24-2005 03:16 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire

PHP:





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


any ideas anyone?


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Old Post Feb-24-2005 03:19 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Resnick
Supreme tranceaddict



Registered: Feb 2003
Location: Toronto

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


___________________
it was the greatest feeling of nothingness i have ever experienced...

Old Post Feb-24-2005 03:29  Canada
Click Here to See the Profile for Resnick Click here to Send Resnick a Private Message Add Resnick to your buddy list Report this Post Reply w/Quote Edit/Delete Message
Michael19
Liverpool FC fan



Registered: Jul 2004
Location: Eire

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


___________________
Liverpool Champions of Europe 2005!


TA's NFL survival League winner 2006!

Old Post Feb-24-2005 03:34 
Click Here to See the Profile for Michael19 Click here to Send Michael19 a Private Message Add Michael19 to your buddy list Report this Post Reply w/Quote Edit/Delete Message

TranceAddict Forums > Main Forums > Chill Out Room > C programming
Post New Thread    Post A Reply

Pages (2): [1] 2 »  
Last Thread   Next Thread
Click here to listen to the sample!Pause playbackdevil trip!! [2003] [1]

Click here to listen to the sample!Pause playbackAirwave - Save Me (Dyyni remix) [2005]

Show Printable Version | Subscribe to this Thread
Forum Jump:

All times are GMT. The time now is 20:06.

Forum Rules:
You may not post new threads
You may not post replies
You may not edit your posts
HTML code is ON
vB code is ON
[IMG] code is ON
 
Search this Thread:

 
Contact Us - return to tranceaddict

Powered by: Trance Music & vBulletin Forums
Copyright ©2000-2026, Jelsoft Enterprises Ltd.
Privacy Statement / DMCA
Support TA!