dear friends, I am a beginner in c programming and I have learned the c++, java as well,
In C I have been asked for a question about how to convert lower case string like any name into uppercase,
and i have read a program for it by pointers and I wanna do it by using typecasting and ascii values for characters so if anyone can help me on that.

typecasting doesn't work. You use the macro toupper() on each character in the string (use a loop)

Example

char c = 'a';
c = toupper(c); // convert to upper-case
printf("%c\n", c);

If you write a small program to loop through all the char's a..z and A..Z

and take the difference of each matching pair ...

the results may give you a 'heads up' on what you may be seeking ?

for( int c = 'a', c2 = 'A'; c <= 'z'; ++c, ++c2 )
   // printout c, c2 and difference between c and c2

Also, the toupper() function won't affect non-alpha characters, such as numbers. So, to be succinct:

/* This is pseudo-code. */
posn = 0;
while (!end-of-string)
{
    string[posn] = toupper(string[posn]);
    ++posn;
}

There are number of means to code the loop including for (int i = 0, j = strlen(string); i < j; i++), etc.

As AD said, typecasting won't work here. You are trying to apply the wrong tool to the job.

With reference to ur query,
char c='b';
char d;
d=toupper(c);//Here it will convert the b letter into B with the help of ASCII values
printf("%c",d);

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.