Solved

!! BASIC question using c++ builder !!

Posted on 2001-06-19
21
268 Views
Last Modified: 2011-09-20


Hey

i am using c++ builder and i was wondering how to add more strings to a line...
i.e
if i open a document that has 300,000 words in it and i wan't to add an 'a' at the begining of every word how would i go about doing this??

if you dont know how to in borland, i alos have microsoft visual c++ 5..

your help will be apresiated...thanks..
0
Comment
Question by:a1a2
  • 8
  • 7
  • 5
  • +1
21 Comments
 

Expert Comment

by:janiv
ID: 6209669
U wanna change all the words, no exceptions ?
0
 

Author Comment

by:a1a2
ID: 6209922
Well i just made the example of changing the words to have a 'a' infront of it...

cause i have a document that contains many words...about over 300,000

they are the english dictonary, german and japanese...but only parts of them

and i wan't to put the name infront of each word so it is understandable....like the word english infront of all the english words...

i.e English -> "some english word"

so as you can see i dont wan't to type them in manually...
i understand that you would use a for loop, but i dont know how to position the cursor so i can add a string to the current text on that line with out over riding..

i hope ya guy's understand what i am trying to say
0
 

Expert Comment

by:janiv
ID: 6209937
How do U differ between english and other words ?
0
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 

Author Comment

by:a1a2
ID: 6209967
hmm, umm dont worrie about that, its very hard to explane what i am trying to achieve in this program....

has anyone got any comments or solutions???

thanks
0
 

Expert Comment

by:janiv
ID: 6209978
There R many solution to this problem.
But I need to know the method.
How are the words are in the documnet?
0
 

Expert Comment

by:janiv
ID: 6209979
U can also send me a portion of the documnet via e-mail,
janivr@simigon.com
0
 

Author Comment

by:a1a2
ID: 6210023
its just a standard .txt document

i just want the ability to add text to the start of each line, with out over riding the current text in that file

if you can, i hope you can answer in terms of borland c++ builder, as i am kind of new to programming, and i asked my teacher and he couldn't figure it out...

i hope ya understand me
0
 

Expert Comment

by:janiv
ID: 6210037
Add the file to memory.
Search for '/n' (new line) in the buffer,
add after each '/n' the string that U want.
copy the buffer to a new file.

(of course, u'll need 2 buffers - (source and destination).
0
 

Author Comment

by:a1a2
ID: 6210051
oh...

is this using c++ builder??
0
 

Expert Comment

by:janiv
ID: 6210070
Add the file to memory.
Search for '/n' (new line) in the buffer,
add after each '/n' the string that U want.
copy the buffer to a new file.

(of course, u'll need 2 buffers - (source and destination).
0
 

Expert Comment

by:janiv
ID: 6210073
I don't think it matters.
It should work also in builder.
0
 

Author Comment

by:a1a2
ID: 6210090
ok, ill have a look, but sounds complicated...

i was hopeing i could use the RichEdit->Lines
and get the array out that way, ill have to do a bit of research on buffers by the sound of it...thanks :)
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6210305
Next is process in C++ Builder
1. Load you file in TRichEdit (see LoadFromFile function)
  Something as:
  RichEdit1->Lines->LoadFromFile(OpenDialog->FileName);

2. Get number of lines
  n = RichEdit1->Lines->Counts
3.
  Make loop for all line
  for (intr i = 0; i < n ; i++)
   {
     tString myLine = RichEdit1->Lines[i];
    //now psevdo code:
      for every line get all words(use delimeters as
       ",. ?" )
     make new line
     Select current line
     change line to new line.
   }
all function for this you can easy find in RichEdit
class (and it will be usefull for you make it!).
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6217124
a1a2???
0
 

Author Comment

by:a1a2
ID: 6221242
yeah?
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6222362
a1a2, do you want more hints about your problem?
Full  BCB tutorial you can find in
http://matthewwu.163.net/c/bcmain.html
 
0
 
LVL 14

Accepted Solution

by:
AlexVirochovsky earned 70 total points
ID: 6240620
No reply, I hope my explanation (see my 1-st comment)
is enuph. Alex
0
 

Author Comment

by:a1a2
ID: 6241161
sorry about no reply, just got back from holidays...
The method you told me, gave me something to do for a while...but i couldn't get it to work....

but when i was trying to sort out another problem, this arrose..and i found that the basic step was to do it this way

RichEdit1->Text = RichEdit1->Text + AnsiString("Blah") + ("blah");

so i included this in your statement, and all works sweet, thanks for tha info...

Later man
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
ID: 6242221
My code was psevdo code: ideas w/o exectly make you assignment.
>>RichEdit1->Text = RichEdit1->Text + AnsiString("Blah") + ("blah");
It is simple insert some text in end of TRichEdit.
Now, is my comment helps you?
0
 

Author Comment

by:a1a2
ID: 6249945
Yes i didn't know the command text
until the other day, it was for a school
assignment...

Like i said thanks for your time

later
0
 
LVL 1

Expert Comment

by:Moondancer
ID: 6811524
I am sorry to see that Asker has not returned to update and finalize this question.  I am, therefore, force accepting this question.  In the event the Asker returns with additional needs related to this question, please respond and continue the collaboration process.
Thank you,
Moondancer
Community Support Moderator @ Experts Exchange
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question