Click here to Skip to main content
Sign Up to vote bad
good
See more: CWindows
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 :
 

#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 3 Feb '13 - 9:22
jahanxb326

Comments
Zoltán Zörgő - 3 Feb '13 - 15:38
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!

2 solutions

Quote:
#include
#include
void main()
{
void letters (char);
char name[10];

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

 
Change to
#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.
  Permalink  
Comments
Espen Harlinn - 3 Feb '13 - 16:55
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.
  Permalink  
Comments
jahanxb - 3 Feb '13 - 15:45
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:00
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:25
AMEEN

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

  Print Answers RSS
Your Filters
Interested
Ignored
     
0 OriginalGriff 198
1 Sergey Alexandrovich Kryukov 159
2 Richard MacCutchan 150
3 Maciej Los 136
4 Tadit Dash 110
0 Sergey Alexandrovich Kryukov 10,264
1 OriginalGriff 7,937
2 CPallini 4,201
3 Rohan Leuva 3,522
4 Maciej Los 3,135


Advertise | Privacy | Mobile
Web02 | 2.6.130523.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2013
All Rights Reserved. Terms of Use
Layout: fixed | fluid