#include<iostream.h>
#include<conio.h>
#include<stdio.h>
#include<string.h>
void main()
{
char s[100],z[10];
clrscr();
cout<<"Enter your name:";
gets(s);
cout<<strupr(s[0]);
cout<<".";
getch();
}

what I am looking for is that when user input deniweb,then it should output D
please help

Thanks

If its a c string you could just print out the first element in the array

cout << your_array[0]; // prints out first element of array

If its a c string you could just print out the first element in the array

cout << your_array[0]; // prints out first element of array

yea i know...but i want first letter should be capital

Thanks

Oh,well you could write a series of if/else if statements like

if(my_array[0]=='a' || 'A')
             cout << "A";
            else if(my_array[0]=='b' || 'B')
             cout << "B";

But that would be extremely long winded

Does this work?

cout<<strupr(s[0]).substring(0,1);

Oh,well you could write a series of if/else if statements like

if(my_array[0]=='a' || 'A')
             cout << "A";
            else if(my_array[0]=='b' || 'B')
             cout << "B";

But that would be extremely long winded

Tried , but not works

Input------------>daniweb
Output---------->Ddaniweb


Thanks

cout<<strupr(s[0]);

This Does Not Work . Because strupr() takes a char* as an argument. So the argument should be a sting having a null character ie: '\0' at the end. But you give a character as its argument. This is the error.

To solve this problem, You can do two things.
First, You can use the function toupper()
But you will need an additional header file #include <ctype.h> or if you have a modern compiler #include <cctype> Or else if you wish to use strupr() itself, heres a little snippet..

char temp[2];
temp[0]=s[0];
temp[1]='\0';
cout<<strupr(temp);
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.