pointer to function

Can anybody help me with this program.

Q.-Write a function that receives a string as an argument and returns after togging the case of every alphabet and create a pointer to your function named as “Toggler”?

i made this code please help...
//Progrma to toggle case of every alphabet
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
#include<iostream.h>
#include<conio.h>
#include<ctype.h>
char string(char []);            //function prototype to toggle the case of string
main()
{
char a[50];
gets(a);
fflush(stdin);
char (*Toggler)(char []);         //function to pointer
Toggler=string;                   //assigning the address of function to pointer
string(a);                        //calling function
cout<<"String after toogling :"<<Toggler;
getch();
}
char string(char a[])           //function defination to toggle the case of string
{
for(int i=0;a[i]!='\0';i++)
{
if(isupper(a[i]))                //changing the case
{
                 a[i]=tolower(a[i]);
}
else if(islower(a[i]))
{
     a[i]=toupper(a[i]);
}
                 
}
return (&a);
}
Last edited on
Topic archived. No new replies allowed.