Welcome to Dream.In.Code
Become a C++ Expert!

Join 137,397 C++ Programmers for FREE! Get instant access to thousands of C++ experts, tutorials, code snippets, and more! There are 2,098 people online right now. Registration is fast and FREE... Join Now!




certain number of character in string ?

 
Reply to this topicStart new topic

certain number of character in string ?

programminglearner
20 Sep, 2006 - 11:54 AM
Post #1

D.I.C Head
Group Icon

Joined: 18 Dec, 2005
Posts: 86


Dream Kudos: 50
My Contributions
hello, for something I'm making I want to know what the 2nd number character is... like say they put 'hello' I want to know the 'e' and then run a different function...

I know the if() { hello() } part, but in the if, what can I put for the 2nd character to = 'e'

I know I didnt explain this too well, but please help
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 11:59 AM
Post #2

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,985



Thanked: 45 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
Is this a character array or an actual String data type?
User is offlineProfile CardPM
+Quote Post

programminglearner
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 12:10 PM
Post #3

D.I.C Head
Group Icon

Joined: 18 Dec, 2005
Posts: 86


Dream Kudos: 50
My Contributions
probly string
User is offlineProfile CardPM
+Quote Post

Appmaker
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 12:22 PM
Post #4

New D.I.C Head
*

Joined: 15 Sep, 2006
Posts: 6


My Contributions
QUOTE(programminglearner @ 20 Sep, 2006 - 12:54 PM) *

hello, for something I'm making I want to know what the 2nd number character is... like say they put 'hello' I want to know the 'e' and then run a different function...

I know the if() { hello() } part, but in the if, what can I put for the 2nd character to = 'e'

I know I didnt explain this too well, but please help

programminglearner,
i think you should use a char pointer, i realy guess that is what u should do
User is offlineProfile CardPM
+Quote Post

Amadeus
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 12:26 PM
Post #5

g++ -o drink whiskey.cpp
Group Icon

Joined: 12 Jul, 2002
Posts: 12,230



Thanked: 40 times
Dream Kudos: 25
My Contributions
string object would work just as well...
User is offlineProfile CardPM
+Quote Post

programminglearner
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 12:34 PM
Post #6

D.I.C Head
Group Icon

Joined: 18 Dec, 2005
Posts: 86


Dream Kudos: 50
My Contributions
could u guys plz provide the if code for me?
User is offlineProfile CardPM
+Quote Post

Jayman
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 01:25 PM
Post #7

Student of Life
Group Icon

Joined: 26 Dec, 2005
Posts: 6,985



Thanked: 45 times
Dream Kudos: 500
Expert In: C#, VB.NET, Java

My Contributions
QUOTE(programminglearner @ 20 Sep, 2006 - 01:34 PM) *

could u guys plz provide the if code for me?

This site has a policy by which you must post the code you have attempted to write on your own. Our members would be more than happy to help get your existing code working, but we will not do your assignments for you.

With that said, here is a link that will get you started on how to search a String object.
http://www.oopweb.com/CPP/Documents/CPPHOW...ng-HOWTO-7.html
User is offlineProfile CardPM
+Quote Post

programminglearner
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 03:12 PM
Post #8

D.I.C Head
Group Icon

Joined: 18 Dec, 2005
Posts: 86


Dream Kudos: 50
My Contributions
I suppose I can understand that rule, except that this isn't for a project nor assignment, I do this under my own time and as something to do for fun. anyways... there is no code yet, I have an idea of sumthing I wanna make, but I cant find that code...
User is offlineProfile CardPM
+Quote Post

programminglearner
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 03:36 PM
Post #9

D.I.C Head
Group Icon

Joined: 18 Dec, 2005
Posts: 86


Dream Kudos: 50
My Contributions
nvm, i figured it out myself
User is offlineProfile CardPM
+Quote Post

violent_crimson
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 05:01 PM
Post #10

New D.I.C Head
*

Joined: 31 Aug, 2006
Posts: 36


My Contributions
char szArray [6] = "Hello";

for (int x = 0; x < 5; x++)
{
cout << szArray [x] << endl;
}

/*
H
e
l
l
o
*/
User is offlineProfile CardPM
+Quote Post

Xing
RE: Certain Number Of Character In String ?
20 Sep, 2006 - 05:07 PM
Post #11

D.I.C Addict
Group Icon

Joined: 22 Jul, 2006
Posts: 723



Thanked: 2 times
Dream Kudos: 1575
My Contributions
@violent_crimson
Code tags please
User is offlineProfile CardPM
+Quote Post

Reply to this topicStart new topic
Time is now: 12/5/08 02:57AM

Live C++ Help!

C++ Tutorials

Reference Sheets

C++ Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month