Solved

!! BASIC question using c++ builder !!

Posted on 2001-06-19
21
265 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
Comment Utility
U wanna change all the words, no exceptions ?
0
 

Author Comment

by:a1a2
Comment Utility
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
Comment Utility
How do U differ between english and other words ?
0
 

Author Comment

by:a1a2
Comment Utility
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
Comment Utility
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
Comment Utility
U can also send me a portion of the documnet via e-mail,
janivr@simigon.com
0
 

Author Comment

by:a1a2
Comment Utility
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
Comment Utility
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
Comment Utility
oh...

is this using c++ builder??
0
 

Expert Comment

by:janiv
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Expert Comment

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

Author Comment

by:a1a2
Comment Utility
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
Comment Utility
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
Comment Utility
a1a2???
0
 

Author Comment

by:a1a2
Comment Utility
yeah?
0
 
LVL 14

Expert Comment

by:AlexVirochovsky
Comment Utility
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
Comment Utility
No reply, I hope my explanation (see my 1-st comment)
is enuph. Alex
0
 

Author Comment

by:a1a2
Comment Utility
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
Comment Utility
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
Comment Utility
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
Comment Utility
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 Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

763 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now