Solved

!! BASIC question using c++ builder !!

Posted on 2001-06-19
21
266 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.
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.

932 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

16 Experts available now in Live!

Get 1:1 Help Now