C programming inquiry
|
View this Thread in Original format
digitalbreach |
this goes out to all with C experience. kinda pulling my hair over this program. have a question for all of u?
lets say I have "if ( ) else ( )"
can I have a while loop in the "if" and a do-while loop in the else part of my program. ???
thanx. is it valid?? :( kinda of a beginner?? |
|
|
tranceaholic |
u dont need the if else just use couple of loops cause if the condition fails in the first one it will go to the seconf one..that is if u got ur question right ot u van include if within the while |
|
|
halo |
first off the structure is:
if ()
{}
else
{};
so you have a block of code for your condition and one for any other case. The else block is like any other block of code. So basically: yes, you can. :D |
|
|
Kirby |
Just curious, what is your assignment? |
|
|
digitalbreach |
thanX
c is a pain. kinda have to get used to it. It helps when I print out my script file and got through the steps in my head. :eek:
well guys....I might have to call upon u again so don't go nowhere
:tongue3 |
|
|
drizzt81 |
quote: | Originally posted by digitalbreach
this goes out to all with C experience. kinda pulling my hair over this program. have a question for all of u?
lets say I have "if ( ) else ( )"
can I have a while loop in the "if" and a do-while loop in the else part of my program. ???
thanx. is it valid?? :( kinda of a beginner?? |
yes u can:
code:
do
{
some code...
if(a >1)
{
while(c<3)
{
printf(c);
c = c + 1;
}
}
else
{
printf("hello world/n");
}
a++
}while(a < 4);
|
|
|
digitalbreach |
just cuz i forgot
if I finished my "blah.c" file and i also have an input file "blah.dat"(bare w/ me)
how do I test it in Unix system
using the unix compiler cc
thanx |
|
|
drizzt81 |
quote: | Originally posted by digitalbreach
just cuz i forgot
if I finished my "blah.c" file and i also have an input file "blah.dat"(bare w/ me)
how do I test it in Unix system
using the unix compiler cc
thanx |
assumig: the .dat file is read within your program
put both in a nice dir
then look http://helpme.scudc.scu.edu/compilers.html <
u want to pay attention to this line:
cc prog1.c -o prog1 |
|
|
digitalbreach |
well I loaded my "blah.dat" file (contains the input needed for program to execute)
also loaded "blah.c" file into Unix using the ftp and put command
next I telnet into unix. I ftp'd it as and anscii file type. supposed to.
so I try to compile my "blah.c" file using cc and given parameters but it gives me errors.
prints out gibberish(guessing it supposed to do that) than it says:"
ld:
Unresolved:
acos
fabs
pow
sqrt
assuming it can't process those commands which are inside my "blah.c" file. probably need to input some sort of math directory??? helppppp?????? |
|
|
drizzt81 |
quote: | Originally posted by digitalbreach
than it says:"
ld:
Unresolved:
acos
fabs
pow
sqrt
assuming it can't process those commands which are inside my "blah.c" file. probably need to input some sort of math directory??? helppppp?????? |
try adding
#include to the top of your source code, then ftp and compile again.. see what happens. That _should_ take care of swrt, pow, acos.. i do not know what fabs does though |
|
|
daydreamer |
had already done that, in the beginning of my program.
any other suggestions. oh..fyi: fabs (absolute value for floats) |
|
|
|
|