Vcoderz Community
We create websites that have it all, beauty & brains
Lebanon Web Design & Development - Coddict
 

Go Back   Vcoderz Community > Computer Zone > Computers & Information Technologies

Notices

Computers & Information Technologies « Everything related to computers and internet. »

Closed Thread
 
Share Thread Tools Search this Thread
Old 03-21-2007   #1
GMA_FOR_EVER
Vcoderz Team
 
GMA_FOR_EVER's Avatar
 
Last Online: 08-23-2011
Join Date: May 2006
Posts: 134
Thanks: 81
Thanked 85 Times in 46 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Thumbs up Need Help In C++

Hi, I just need some Help in C++. It has been long ago the last time I wrote a program. So I almost forgot everything.

1. So, I need a program that takes as input a STRING of characters (small letter), And TRANSFER IT INTO CAPITAL LETTERS.

NOTE: I DO NOT need PRE DEFINED FUNCTIONS. IE: I do not want to use toUpper & toLower. (that's the main problem for me )

It's OK if you want to use IsUpper & IsLower for checking (Boolean) only.

2. At the same program, I need another function that takes as input a string and try to search for a specific consicutive characters
IE: I choose for example to search for the characters "ode"
When the user input a string of characters: " I like vcoderz " for example, The output should be: ode is found. Else, nothing is found.

I Hope I was clear in explaining the program I need. Hope somebody can help me.

The first part is more Important to me (changing the letters) So PLZ TRY HARD TO HELP ME

Thanks in advance!!

GMA_FOR_EVER


GMA_FOR_EVER is offline  
Old 03-21-2007   #2
Moophz
Registered Member
 
Moophz's Avatar
 
Last Online: 09-05-2008
Join Date: Mar 2007
Posts: 15
Thanks: 0
Thanked 2 Times in 1 Post
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: Need Help In C++

I made this for the 1st function you requested using C++.
Tested and working
It transposes each small character into capital letter, and every other character remais the same.
For ex:
vcoderz -> VCODERZ
v123Coderz -> V123CODERZ

But didn't get the 2nd function.


Code:
#include <iostream>
#include <string>
using namespace std;
#define N 0
int main()
{
char str[N];                //array or character forming a string
void small(char [] );       //calling the f*ckin function
cin >> str;                 
small(str);
system("pause");

}


void small(char text[])
{
char* t;
t = text;
while (*t != '\0')          //While the character is not = end of string
{
      if ((*t >= 97) && (*t <= 122))
      {*t = *t - 32;         //The difference between both capital
      t++;                  //and small letters is 32 (A-a=32)
      } 
else t++;  
 }                       //Based on the ASCII table
cout << text << endl;

}
Moophz is offline  
Old 03-21-2007   #3
Moophz
Registered Member
 
Moophz's Avatar
 
Last Online: 09-05-2008
Join Date: Mar 2007
Posts: 15
Thanks: 0
Thanked 2 Times in 1 Post
Groans: 0
Groaned at 0 Times in 0 Posts
Talking Re: Need Help In C++

Here is your 2nd function
You can implement it the way it is in the program above


Code:
//start function definition
void find(char text[],char ch )
{ char* t;
t = text;
bool found = 0;

while (*t != '\0' && !found)
if (*t == ch)
{cout <<  "Character '" << ch << "' found" ;
found =1;
}
else t++;

if (*t != ch)
cout <<  "Character '" << ch << "' not found" ;
}
__________________
We Do Not Worry About Warnings, We Only Care About Errors.

Last edited by Moophz; 03-21-2007 at 06:07 PM.
Moophz is offline  
Old 03-21-2007   #4
GMA_FOR_EVER
Vcoderz Team
 
GMA_FOR_EVER's Avatar
 
Last Online: 08-23-2011
Join Date: May 2006
Posts: 134
Thanks: 81
Thanked 85 Times in 46 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: Need Help In C++

Thank you Moophz very much... I really appretiate your help..
Hope everything will be ok.

But I have a question:

The first function, the compiler reads only till the first space, IE: It only reads the first word. So how can I let the function read all the string entered by the user ? I think that the while loop: ( while *t != '\0' ) should be changed, IE: we must change the '\0' into another character. Hope you can help me.

Last edited by GMA_FOR_EVER; 03-21-2007 at 09:35 PM.
GMA_FOR_EVER is offline  
Old 03-21-2007   #5
Moophz
Registered Member
 
Moophz's Avatar
 
Last Online: 09-05-2008
Join Date: Mar 2007
Posts: 15
Thanks: 0
Thanked 2 Times in 1 Post
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: Need Help In C++

No the \0 symbolises the end of the string, or last character in the array string
The main problem was when we used the 1st "cin >>"

Code:
just replace cin >> str;   (line 9)
with cin.getline (str,256) ;

Have a nice day.
__________________
We Do Not Worry About Warnings, We Only Care About Errors.

Last edited by Moophz; 03-21-2007 at 11:09 PM.
Moophz is offline  
Old 03-22-2007   #6
GMA_FOR_EVER
Vcoderz Team
 
GMA_FOR_EVER's Avatar
 
Last Online: 08-23-2011
Join Date: May 2006
Posts: 134
Thanks: 81
Thanked 85 Times in 46 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: Need Help In C++

AH OK MAN thx a lot ! It works

I Just need two more functions :

1. A fuction where you enter a string containing first name, middle name, last name :

EX: IF the user entered: " John Albert Doe " The Output output should be:
"Doe, John A".

2.
A second funtion where the User ente a string And the Function should Check if the string is PALINDROM.

Palindrom Means if you read the string from left or right it remains the same. EX: ABBA , 463364, MADAM, ....
GMA_FOR_EVER is offline  
Old 03-22-2007   #7
god
Registered Member
 
god's Avatar
 
Last Online: 02-14-2010
Join Date: Mar 2006
Posts: 846
Thanks: 71
Thanked 293 Times in 217 Posts
Groans: 0
Groaned at 0 Times in 0 Posts
Default Re: Need Help In C++

write your own code!!!......... w khaffif chwayyit colors thats creepy
__________________
--Capitalisation is the only difference between "I helped my uncle Jack off a horse" and "I helped my uncle jack off a horse" !!
http://img482.imageshack.us/img482/4889/hell7ta.jpg

Last edited by god; 03-22-2007 at 09:38 PM.
god is offline  
Closed Thread

  Vcoderz Community > Computer Zone > Computers & Information Technologies



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 06:15 AM.


Lebanon web design and development
Powered by vBulletin® Version 3.8.3
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Share