0
#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

4
Contributors
6
Replies
7
Views
7 Years
Discussion Span
Last Post by Sky Diploma
0

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
0

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

-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

0

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

0
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);
This article has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.