Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C Windows
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:22am
jahanxb327
Comments
Zoltán Zörgő at 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!
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

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 at 3-Feb-13 16:55pm
   
Good point :-D
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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 at 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 at 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 at 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)

  Print Answers RSS
0 CPallini 405
1 Sergey Alexandrovich Kryukov 272
2 OriginalGriff 165
3 George Jonsson 159
4 Richard MacCutchan 110
0 OriginalGriff 6,344
1 Sergey Alexandrovich Kryukov 5,890
2 CPallini 5,175
3 George Jonsson 3,559
4 Gihan Liyanage 2,522


Advertise | Privacy | Mobile
Web03 | 2.8.140916.1 | Last Updated 3 Feb 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100