473,387 Members | 1,597 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

c++ StreamReader Substring visual studio.net

**** PLEASE HELP ME ************************************
***** SEE BELOW*****************************************
StreamReader* sr = File::OpenText(path);
try {
String *s = "";

int place = 0; // looks for the ID FIELD
String *ID_val = "IAO_"; // ID is the leader if the id
String *ID;
String *temp;
while (s = sr->ReadLine()){
place = s->IndexOf(ID_val);
if ( place == 1)
{
Console::WriteLine(s->Substring(1,8)); //this works
temp = s->Substring(1,8); // this is my problem
}}
// i just want to save the substring as a string.

Nov 16 '05 #1
2 2801
So what is the problem?

Also, you realize that IndexOf returns the zero based index, so unless
you expect the place to be at the second character, you might want to
compare it against zero.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

<co******@gmail.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
**** PLEASE HELP ME ************************************
***** SEE BELOW*****************************************
StreamReader* sr = File::OpenText(path);
try {
String *s = "";

int place = 0; // looks for the ID FIELD
String *ID_val = "IAO_"; // ID is the leader if the id
String *ID;
String *temp;
while (s = sr->ReadLine()){
place = s->IndexOf(ID_val);
if ( place == 1)
{
Console::WriteLine(s->Substring(1,8)); //this works
temp = s->Substring(1,8); // this is my problem
}}
// i just want to save the substring as a string.

Nov 16 '05 #2
temp = s->Substring(1,8); // this is my problem
this line will not work however the line before this one works fine.
why will substring not work with stringreader? please help me..........

Nov 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: blah | last post by:
what i want to do is read in a .ged file and find all the names in the file and then add them to a listbox. this is what i have and it works but what can i do better? thanks, Rob public...
7
by: Hans | last post by:
Hi, I need to process files that are created in UTF-7 format. This works fine upto the point where a '+' character (0x2B/43) appears in the line. The string is mutilated... The reader appears...
6
by: No_Excuses | last post by:
All, I am interested in reading the text of a web page and parsing it. After searching on this newgroup I decided to use the following: ******************************* START OF CODE...
4
by: Astronomically Confused | last post by:
using System; using System.Collections; using System.IO; using System.Net; using System.Net.Sockets; using System.Threading; class HttpProcessor { private Socket s;
21
by: JoKur | last post by:
Hello, First let me tell you that I'm very new to C# and learning as I go. I'm trying to write a client application to communicate with a server (that I didn't write). Each message from the...
5
by: Lyle | last post by:
Hi. What is the best way to check for EOF when using the streamreader? I am using a do loop. Following is what I have tried but all end in an error when eof is reached. 1. Adding 'until line...
4
by: KenLee | last post by:
help!! I used StreamReader and StreamWrite. the problem is it doesn't write all readline. For example it read 100 line and write 51lines. this is codes. class kenlee{ private StreamWriter sw...
9
by: Matt Bailey | last post by:
I am writing an ASP page with a C# backend. This page uses a StreamReader to input a file and pull out a specific section of the text based on markers inside. While the code I have works, I get a...
2
by: asem0525 | last post by:
I have this kind of exception: System.IO.IOException: The process cannot access the file 'E:\asem\Visual Studio 2005\WebSites\WebSite1\App_Data\Books.txt' because it is being used by another...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.