CFanatic

Go Back   CFanatic > Programming > C++ Programming

Join CFanatic Forum Now

How to find a substring in a String. topic posted under C++ Programming which is a part of Programming category in CFanatic Forum
Reply
 
Thread Tools Display Modes
  #1  
Old 03-25-2010, 07:30 PM
Member
 
Join Date: Feb 2010
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
techme is on a distinguished road
| More
Thumbs down How to find a substring in a String.

Hi All,

Is there a routine to find a substring in a String?
I would like to have a routine that can be used in this way:

String* S;
String* SubStr = ".";
do
{ S = Console::ReadLine() }
while(Pos(SubStr, S) == 0);
//Pos returns the index of the first letter of the substring inside the string. And if it doesn't find the substring, then it returns 0.
Reply With Quote
  #2  
Old 03-25-2010, 07:31 PM
Member
 
Join Date: Feb 2010
Posts: 86
Thanks: 0
Thanked 0 Times in 0 Posts
techme is on a distinguished road
| More
Re: How to find a substring in a String.

I was looking for a routine that works with .net and not the old C++.

I found what I was looking for though:

String* S;
String* SubStr = ".";
do
{ S = Console::ReadLine() }
while(S->IndexOf(SubStr) < 0);
Reply With Quote
  #3  
Old 04-11-2010, 12:49 PM
Junior Member
 
Join Date: Mar 2010
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
davidk is on a distinguished road
| More
Re: How to find a substring in a String.

Do you really sure what this line of code does?
Code:
String* SubStr = ".";
It seems you are assigning the random address to your pointer-to-string variable...
Reply With Quote
Reply

Thread Tools
Display Modes

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Interested to find out in how often I can be here griffiniozy Introduce yourself 2 06-27-2009 04:16 AM
Please, help me to find sites to fix some bugs on my PC. brierieTago Introduce yourself 2 01-25-2009 02:39 AM
How to insert a string into string? Tran C Programming 3 05-21-2008 09:51 PM
how to find the running exe and kill that exe vidhya Win32 Programming 9 06-14-2007 02:37 AM

 

Advertisement

CFanatic Search
Custom Search

Advertisement

All times are GMT -5. The time now is 04:33 AM.



Powered by vBulletin® Version 3.7.4
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO ©2010, Crawlability, Inc.
Cfanatic.com is a premier member of the IDG TechNetwork. For advertising opportunities contact here
Get Paid for Working on Projects Matching Your Expertise at Go4Expert's Jobs Board