Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

that tok thing didn't work for me s

Status
Not open for further replies.

lisal

Programmer
Sep 22, 2005
5
US
that tok thing didn't work for me so i tried this.
I wanted to search an outfile for the "," again, and until i find that I want to be able to add up the number of characters and store them in memory. Once the "," is found i want it to output the characters that are stored in memory and the "," . What's wrong with this that I wrote...
p.s. how do I declare characters so it knows it's an array...thanx

while(out3)
{
out3.get(punc);
while(punc != ','){
count +=1;
for(int i = 0; i <=count; i++)
if (punc = ',')
finaldoc << characters;}
}
 
I dont fully follow what you are trying to do. I assume that &quot;out3&quot; is of type ifstream. You way of reading in a file a character at a time will work but the loop above will be an infinite loop if you dont have a file full of commas (and commas only)

If you could send me the document or a sample of it in an attachment I would be able to help out more.

Matt

zyrenthian@home.com
 
OK, here's the post I put in your other thread. I wrote it out as a whole program which compiles in VC++ as a console application and runs.
It outputs &quot;Newport News,&quot;


#include <stdlib.h>
#include <iostream.h>
#include <string.h>

int main()
{
[tab]char City[100] = &quot;Newport News, VA&quot;;
[tab]char* city = 0;
[tab]char* p;
[tab]int i = 0;
[tab]
[tab]for(p=City; *p!=0; p++, i++)
[tab]{
[tab] if(*p == ',')
[tab][tab]{
[tab][tab][tab]i++; // this is because you want to keep the comma
[tab][tab][tab]break;
[tab][tab]}
[tab]}
[tab]
[tab]city = new char[i + 1];
[tab]strncpy(city, City, i);
[tab]city[ i ] = 0;

[tab]if(city)
[tab][tab]cout << city;
[tab][tab]
[tab]delete city;
[tab]return 0;
}
[tab]
--Will Duty
wduty@radicalfringe.com

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top