|
Please read this link HOW TO ASK A QUESTION - C / C++ / MFC Discussion Boards[^] near the top of this page, specifically #2. Many people here are very knowledgeable and will help you with questions during your coding endeavors, but generally will not serve up code to order.
"the debugger doesn't tell me anything because this code compiles just fine" - random QA comment
"Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst
"I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle
|
|
|
|
|
I would use the C standard library functions fopen , fread (full file), fgets (read line), strchr (find NL), and strncmp (find match).
A quick try from scratch without error checking (therefore untested):
#include <stdio.h>
#include <sys/stat.h>
struct stat st;
stat(file2, &st);
char *buf = new char[st.st_size + 1];
FILE *f2 = fopen(file2, "rb");
fread(buf, 1, st.st_size, f2);
fclose(f2);
buf[st.st_size] = 0;
unsigned lines = 0;
char *p = buf;
while (NULL != (p = strchr(p, '\n')))
{
p++;
lines++;
}
char **lineptr = new char* [lines+1];
p = buf;
unsigned i = 0;
lineptr[0] = buf;
while (NULL != (p = strchr(p, '\n')))
{
lineptr[++i] = ++p;
}
char linebuf[1024];
FILE *f1 = fopen(file1, "rb");
FILE *f3 = fopen(file3, "wb");
do
{
if (NULL == fgets(linebuf, sizeof(linebuf), f1))
break;
if (0 == linebuf[0])
break;
if ('\r' == linebuf[0] || '\n' == linebuf[0])
continue;
for (i = 0; i < lines; i++)
{
if (0 == strncmp(linebuf, lineptr[i], strlen(linebuf)))
break;
}
if (i >= lines)
fputs(linebuf, f3);
}
while (!feof(f1));
fclose(f3);
fclose(f1);
delete [] lineptr;
delete [] buf;
|
|
|
|
|
Member 13433022 wrote: Since I do not have experience in programming,
What does that mean?
If you have zero experience then this shouldn't be the first thing to undertake.
There are other tools besides the one I mentioned and one of them might allow you to get close enough, by messing with configuration to either produce exact result or one that you can manually modify to reach a result.
If this sort of task is something that you are going to be doing on a normal basis then you should pick a language and start learning it.
As a recommendation unless you want to be a programmer, I would use perl (a language) as an ad hoc tool to supplement other occupations.
If however you want to program then you should start with one of the object languages, probably java or C#. Those would be easier initially, I think/guess, than C++. However regardless of language choice it is going to be better, as the first step, to either take an actual class or follow a tutorial exactly, unless you have an actual real world person that can help you when problems show up. The very first steps in programming can be very difficult when relying on the web.
|
|
|
|
|
Beyond Compare[^] can do something like that, though to actually do the write (vs. cut and paste) can be a little tricky.
|
|
|
|
|
Take file A and split into paragraphs. Search file B for each paragraph appending them to file C when not found. Swap files A & B then repeat.
You could do this in a single command line in bash I reckon.
|
|
|
|
|
Hi,
I have a windows service (system level) and a user level MFC app (non admin rights).
I need to send some notification to service from MFC app on some instance.
Is there any way to do it?
|
|
|
|
|
|
We have an application to do chemical process engineering calculations. As an inclusion, we require a graphics builder to be integrated to bring dynamics into it. So we need to develop a graphics builder kind of application.
It should have provision to create and add a new graphics pages and to save the graphics page which is to be linked to the existing application which does the calculations.
It should have a tool box with symbols of various equipments and when we drag and drop a symbol into the graphics page, it should be placed appropriately and connected to various other equipments.
Can you please suggest me how to start and proceed as i dont know how to create drag and drop graphics builder.
|
|
|
|
|
|
Is it possible to get some sample applications?
|
|
|
|
|
|
Hi
I have a number of rich edit classes in my project. Defined basically as such
class Myrich : public CrichEditCtrl they all have a default constructor with no parameters
I now wanted to extend their functionality with paging (up or down) cursor selection etc.
So I wrote a class KeyStroke. I declared KyStroke(s) in each of my classes as such
KeyStroke mykeys; in my .h class definitions. My constructer for KeyStroke takes 2
parameters the number of lines in the rich edit and a pointer to a rich edit class
So that meant I would have to modify my rich edit constructor as such
MyRich::MyRich() ---> MyRich::MyRich(int numlines, CRichEditCtrl* myrichptr) : KeyStroke(int numlines, CRichEditCtrl* myrichptr)
I am getting all sorts of errors with this such as "int" unexpected and KeyStroke no default contsructor
|
|
|
|
|
If you create a parameterised constructor for a class you must also provide a default parameterless one.
class KeyStroke
{
public KeyStroke(int numlines, CRichEditCtrl* myrichptr)
{
}
public KeyStroke()
{
}
|
|
|
|
|
I did that I am still getting errors as stated below
\progedit.cpp(13): error C2062: type 'int' unexpected
1> progdialog.cpp
while intellsense says class KeyStroke
"KeyStroke" is a nonstatic data member or base class of class Cprogedit
I have KeyStroke in Cprogedit.h as KeyStroke mystroke; in the public section of the class
I have defined a constructor for Cprogedit which will provide the paramters for Keystroke
as such
CProgedit::CProgedit(int numlines, CProgedit* editptr) : KeyStroke(int numlines, CProgedit* editptr)
KeyStroke::KeyStroke()
{
}
KeyStroke::KeyStroke(int numlines, CRichEditCtrl* editptr)
{
max_line = numlines;
edit_ptr = editptr;
}
|
|
|
|
|
Sorry, I cannot make head or tail of that. Can you show the class definition for Keystroke and indicate exactly where the error message occurs?
|
|
|
|
|
Not home now Dr appt but I'll paste the entire output in about 1 and 1/2 thanks so so so much
|
|
|
|
|
Richard, Richard Andrew X64 got me pointed in the right direction
For the Class Declaration
KeyStroke mykeys;
inside
class Cprogedit : public CrichEditctrl
this was the necessary constructer
CProgedit::CProgedit(int numlines, CProgedit* editptr) : mykeys(numlines, editptr)
|
|
|
|
|
ForNow wrote: CProgedit::CProgedit(int numlines, CProgedit* editptr) : KeyStroke(int numlines, CProgedit* editptr)
This is a problem. While you're declaring the CProgedit constructor on the left-hand side, the part on the right-hand side is actually a call, so you wouldn't put the data types of the aguments. In other words, try the following:
CProgedit::CProgedit(int numlines, CProgedit* editptr) : KeyStroke(numlines, editptr)
Let me know if this helps.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Richard
Thanks almost I got a compiler error saying KeyStroke not a member ... and that's right KeyStroke was a type as I declared KeyStroke mykey. However when I declared I got a clean build
CProgedit::CProgedit(int numlines, CProgedit* editptr) : mykey(numlines, editptr)
|
|
|
|
|
I'm glad you got it fixed.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
KeyStroke mykey; defined in Cprogedit.h
CProgedit::CProgedit(int numlines, CProgedit* editptr) : mykey(numlines, editptr)
KeyStroke::KeyStroke(int numlines, CRichEditCtrl* editptr)
Cprogedit* myrich = new Cprogedit((int) 30, myrich);
DO you think this will work. What I mean is the two parameters are being passed to KeyStroke
but will myrich have a vaule before KeyStroke constructor is called
|
|
|
|
|
I think that will definitely not work. Because it passes an uninitialized value into the constructor before it returns the new pointer.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
Is there any way this is do-able
What I mean by that is I am sure you know MFC internals better than me does get the storage
for the Object class BEFORE it calls one or all of the member classes/object in the class
For some reason I thought that it did
|
|
|
|
|
I don't know what to tell you because you need to explain what you are trying to accomplish.
If we can talk about what you want to accomplish, then we can probably find a solution.
Why do you think you need to do it this way?
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I wrote a number of rich edit classes after finishing I realized they would all have common functionality
1) processing KeyStrokes
2) cursor select
3) Finding data
I decided to encompass all of this in a class called KeyStroke which would expand functioality on a EditCtrl object
so I declared KeyStroke mykey1; etc; 2 3 ...
The constructor of KeyStroke takes a RicheditObject it was my understanding that when "new" build a class/object the First thing it does is allocate storage for the class/object and then
call member classes which is why I thought this was doable
Thanks
|
|
|
|