Click here to Skip to main content
15,896,207 members
Please Sign up or sign in to vote.
2.00/5 (2 votes)
See more:
i got a problem in compiling my program i want to make a function with parameters for char values conversion i.e lower to upper or upper to lower

here is the C code :


XML
#include<stdio.h>
#include<conio.h>
void main()
{
void letters (char);
    char name[10];


    printf("\n Enter words:");
    scanf("%s",&name);
    letters(name);
    getch();
}
  void letters (char nome[10])
  {
      int a;

    for(a=0;a<=9;a++)
    {
        if(nome[a]<=90&&nome[a]>=65)
        {


        nome[a]+=32;
        printf("%c",nome[a]);
        }
        else if(nome[a]<=122&&nome[a]>=95)
        {
            nome[a]-=32;
        printf("%c",nome[a]);
        }
        }

}
Posted
Comments
Zoltán Zörgő 3-Feb-13 15:38pm    
Well, it is a good homework task and you will learn from it. First of all, this is no question. You have not said anything about a problem. That's good. But you will have to refine your solution, since it has several flaws... Keep up!

Quote:
#include<stdio.h>
#include<conio.h>
void main()
{
void letters (char);
char name[10];


printf("\n Enter words:");
scanf("%s",&name);
letters(name);
getch();
}


Change to
C
#include<stdio.h>
void letters (char *);
int main()
{
    char name[10];
    printf("\n Enter words:");
    scanf("%s",name);
    letters(name);
    getchar();
    return 0;
}


BTW even fixed this way, your program is not very robust.
 
Share this answer
 
Comments
Espen Harlinn 3-Feb-13 16:55pm    
Good point :-D
There are a heap of problems here so rather than try to write the whole thing for you (I'm a C++ but not a 'C' programmer) I'm going to suggest that you lookup the standard toupper and tolower C library functions. Along the way you will undoubtedly find code to read a string of characters from stdin in a sensible way in 'C'.
The problem you will then face is the one of trying to find a general solution to a very large problem. How do you convert a Chinese Kanji expressed as UTF-8 into upper case when there is no upper case in Chinese? How about Telugu? If you want to take it that far www.unicode.org will be of interest.
I recommend the items in red in this text as search terms to enter into your favourite search engine.
 
Share this answer
 
Comments
jahanxb 3-Feb-13 15:45pm    
well sir as a college fresh student the professor says : use only those things that i tought you if you know other functions then explain them to me then i allow but that will be not a good programing technique , programing is a technique in which you have limited sources and have many ideas to create , that's why i am following him so i can't use special functions .. :|
Matthew Faithfull 3-Feb-13 16:00pm    
I had similar professors, they made me smile. I did many things as they said and a few differently to see if they would understand them. I had to make sure I understood first so I could explain if they didn't like it. Now I earn more than them. I hope it goes as well for you :-)
jahanxb 5-Feb-13 1:25am    
AMEEN

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900