not calling function inside switch case???
int add_provider(struct pstentry *pst)
{ int length; printf("length:"); scanf("%d",pst->length); return; } int main() { int i; printf("1.Add Provider"); printf("2.Add User"); printf("Enter your choice:"); scanf("%d",&i); switch(i) { case 1: { int add_provider(struct pstentry *pst); break; } In the above program its not calling the function inside switch case. It is asking for the choice, once we give the value for switch case after that it comes out of program. please let me know the solution |
For one, you have an extra curly brace in the case. Secondly, you need to declare pst first, and then pass it to the function. You can't do both at once.
|
Quote:
Example: Code:
switch(foo) EDIT: For C, the braces just serve as a good way of denoting the beginning and end of the case block. It's a formatting thing. Quote:
A correct call to the function would look like: Code:
result = add_provider(&provider_object); Code:
add_provider(&provider_object); Code:
add_provider(NULL); -Aaron |
All times are GMT -5. The time now is 06:55 PM. |