"Sridhar_Gadda" <sr**********@yahoo.com> writes:
I am new to C and I have written a code but
#include <stdio.h>
main()
{
init_funtion();
}
void init_funtion();
{
int i;
for (i =1; i < 10; i++)
{
switch (i)
{
case 1 :
{
printf("my vlaue is 1");
break;
}
case 2 :
{
printf(" my value is 2");
break;
}
and so on till case 9
}
}
}
but when I complile the error is "the statement for is of no effect" is
that mean in for loop I cannot define my switch satement......in general
switch statement can be written in for loop ???
That's not the same as the program you actually compiled, is it? The
error message was probably the result of a minor error in your code,
most likely an extra semicolon on the line with the "for". You've
posted code with *different* minor errors, particularly the extra
semicolon on the "void init_funtion() line. When I compiled the code
you posted (with the "and so on till case 9" commented out), I got a
syntax error, not a complaint about the for loop.
We can't tell you what the problem is unless you post the *exact* code
that you compiled. Don't re-type it, cut-and-paste it. And don't
paraphrase (the "and so on till case 9"), but reduce the code as much
as you can.
(BTW, it's spelled "function", not "funtion". C doesn't care whether
your identifiers are correctly spelled as long as you're consistent,
but your readers will care.)
--
Keith Thompson (The_Other_Keith)
ks***@mib.org <http://www.ghoti.net/~kst>
San Diego Supercomputer Center <*> <http://users.sdsc.edu/~kst>
We must do something. This is something. Therefore, we must do this.