C++ String Arabic
C++ String Arabic
February 6, 2012
DOC
1
char
ASCII
.1Byte
char
:
:iomanip setw
setiosflags
) :setw(n ) (
n ..
) (
:
''a' < 'b
''A' + 5 < 'H
) :setiosflags(ios::left
) (setw
.
>#include <iostream
>#include <iomanip
;using namespace std
)(int main
{
;'char a = 'a
;'char A = 'A
char
:char
'\0'
#inc
clude <iost
tream>
usin
ng namespac
ce std;
fine MAX_SI
IZE 30
#def
// const
tant
ength(char str[]);
int get_str_le
d convert_t
to_upper(char str[]);
void
void
d convert_t
to_lower(char str[]);
300 str
:
29
.'\0'
:
cin
.cinn
int main()
{
r[MAX_SIZE];
/*char str
cout << "\
\n";
cout << " # Enter a string(max 29 charact
ter): ";
r;
cin >> str
cout << "\
\n";*/
//char str
r[] = "Hello Students!!\n >> Tod
day is:
char str[]
] = {
'H', 'e', 'l',
'e', 'n', 't',
' ', 'T', 'o',
' ', 'M', 'o',
'e', 'b', 'r',
'6', ',', ' ',
};
'l',
's',
'd',
'n',
'u',
'2',
'o',
'!',
'a',
'd',
'a',
'0',
' ',
'!',
y',
'y
'a
a',
'r
r',
'1
1',
Mo
onday, February 06, 20
012";
'S', 't
t', 'u', 'd
d',
'\n', ' ', '>', '>',
' ', 'i
i', 's', ':',
'y', ',
,', ' ', 'F
F',
'a', 'y
y', ' ', '0
0',
'2', '\
\0' /*very important*/
/
convert_to
o_lower(str);
cout << "\
\n To Lower Case:\n ---------------\n " <<
< str << "\n\n ";
system("pa
ause");
return 0;
}
ength(char str[])
int get_str_le
{
int len = -1;
[++len] != '\0');
while(str[
return len
n;
}
d convert_t
to_upper(char str[])
void
{
int len = get_str_length(str);
for(int i = 0; i < len; i++)
r[i] >= 'a' && str[i] <= 'z')
if(str
st
tr[i] = 'A' + str[i] - 'a';
}
d convert_t
to_lower(char str[])
void
{
int len = get_str_length(str);
for(int i = 0; i < len; i++)
r[i] >= 'A' && str[i] <= 'Z')
if(str
st
tr[i] = 'a' + str[i] - 'A';
}
string
#inc
clude <iost
tream>
#inc
clude <stri
ing>
usin
ng namespac
ce std;
d print_str
ring_array(string s);
void
int main()
{
r = "Hello Students!!\
\n >> Today
y is: Mond
day, February 06, 2012
2";
string str
cout << "\
\n Original string:\n-------------------------- \n "
<< st
tr << "\n\n";
print_stri
ing_array(str);
cout << " --------------------------\n\n"
";
r1, str2, str3;
string str
cout << " Enter 1st string: "; cin >> str
r1;
r2;
cout << " Enter 2nd string: "; cin >> str
r1 + ' ' + str2; // co
oncatinatio
on
str3 = str
cout << " str1 + str2: " << str
r3 << "\n";
;
:
cin
.cin
ause");
system("pa
return 0;
}
d print_str
ring_array(string s)
void
{
cout << " String Characters **{
{\n";
for(int i = 0; i < s.length(); i++)
{
< " '";
cout <<
if(s[i
i] == '\n') cout <<"\\
\n";
else cout
c
<< s[i];
cout <<
< "'";
if((i+
+1)% 10 == 0)cout << "\n";
}
th() % 10 != 0) cout <<
< "\n";
if(s.lengt
cout << " }**\n";
}