Go4Expert

Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   function calling (http://www.go4expert.com/forums/function-calling-t627/)

musicmancanora4 12Mar2006 07:09

function calling
 
I just want to be able to successfully call the validate Month function inside the getMonth function.. it works when i call getUserInput() but i get type cast errors if i try it with this function. Any idea as to how i can write it up? thnxs




Code:

unsigned getMonth()
{
 
  /*** declare variables*/
 
  unsigned  i;
  int  valid = 0;
  char *prompt = "Please enter a month between 0 - 12\n";
  char *month;
 
 
 
  do
  {
 
  month = getUserInput(prompt);
  /* in here i want to call the validateMonth() fucntion*/

  }
  while(!valid);
  /*printf("hello %s",month);*/
  /*printf("Please enter a month between 0 - 12\n");*/
 
 
 
  return EXIT_SUCCESS;

}

Code:

unsigned validateMonth(unsigned month)
{
    unsigned m;
    while(month<0 || month>12)
    {
       
        printf("Month error 0 or less or equal to 12 please\n");
       
    }

    return m;
}


shabbir 12Mar2006 10:37

Re: function calling
 
Because the prompt is a character pointer and the function argument for validateMonth is unsigned. i.e. integer.

coderzone 12Mar2006 10:40

Re: function calling
 
Isnt the error evident enough.

musicmancanora4 12Mar2006 10:58

Re: function calling
 
the code i have posted is error free. But what im trying to say is that when i try to write the function call for it i get a type cast error for some reason.

so with the above code how can i call the validateMonth() function inside the getUserInput() function

musicmancanora4 12Mar2006 11:41

Re: function calling
 
Its kewl guys i did it yey! thnxs

shabbir 12Mar2006 14:23

Re: function calling
 
Quote:

Originally Posted by musicmancanora4
Its kewl guys i did it yey! thnxs

Good that its done. Probably you are calling with the different variable type.


All times are GMT +5.5. The time now is 09:23.