|
Hi
The following information is in a .txt file. I nead to read through it, pick out certain parts and send the information to a DB.
Memory SM, location 1
Name: John Doe
Number: +12345
Memory SM, location 2
Name: Jane Doe
Number: +54321
Memory SM, location 3
Name: Jack Doe
Number: +112233
...
Here is the code I use to get the info I need from the first 3 lines:
/***********************************************/
FILE *stream;
stream = fopen( "number", "r" );
char bufLine1[30], bufLine2[30], bufLine3[30];
fgets(bufLine1, 30, stream);
fgets(bufLine2, 30, stream);
fgets(bufLine3, 30, stream);
fclose( stream );
char *pNext1 = &bufLine1 [21];
char *pNext2 = &bufLine2 [9];
char *pNext3 = &bufLine3 [11];
strcpy(bufLine1, pNext1);
strcpy(bufLine2, pNext2);
strcpy(bufLine3, pNext3);
//information sent to database
/***********************************************/
Is there a way that I can put this in a loop and then start reading the 4th, 5th & 6th line and send their details off to the DB. And the go on to the 7th, 8th & 9th etc? I persume it's something like a pointer in a text file but I'm not sure how to do this.
Thanks for any help.
Alan
|
|
|
|
|
Yes,
just don't close the stream and do a while(EOF)!
Cheers
Al
|
|
|
|
|
1. whether the length of bufLine1 is more than 22, if not,
the pointer(pNext1) maybe is out of control
2. you can use substr function
|
|
|
|
|
I made a VC6 freeware image file browser dedicated to Poser - the 3D character animator. The app works fine (about 5000 users) but I've got a W2K user with a strange problem. When he loads both my browser and Poser, Poser slow down. Each of the application alone work fine.
I just wonder if there is a tool or technic that could help me see what happens ? Any idea would be welcome, of course )
My browser is compiled under W98, I know the first thing to do is to recompile under W2K but I can't afford a new release untill late May. My purpose is to find the way to solve the problem so that next version is clean.
Thank you
Yarp
|
|
|
|
|
Do you know for sure that it is a memory problem?
Have you looked at the possibility that you may be locking files, or both programs are using files at the same time and that causes problems?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
Hi Kilowatt,
Yep, this is a possibility. My browser does open files on a specific folder to display inner informations (but I only open those files with read access with fopen function).
The user told me the slowdown occurs each time he loads the 2 apps. So it seems impossible this come from a file lock. Moreover as I told above there are thousand other users and this is the only report of such a problem.
Thank for taking time to reply,
Yarp
|
|
|
|
|
After he opens both apps, and the slow down occurs, if he closes down your app, does Poser speed up again? Does your app run slowly when both apps are running?
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
> After he opens both apps, and the slow down occurs, if he closes down your app, does Poser speed up again?
Thats a pretty good question, I will ask him. What if the answer is Yes or No ?
Does your app run slowly when both apps are running?
No, just Poser. Poser is slow and sometimes even crashes. Memory management in Poser is poor and Poser crash are frequent (the reason for this is that Poser is a Mac based application and the whole GUI has been rewritten, I suppose memory management too).
Yarp
|
|
|
|
|
yarp wrote:
> After he opens both apps, and the slow down occurs, if he closes down your app, does Poser speed up again?
Thats a pretty good question, I will ask him. What if the answer is Yes or No ?
If the answer is yes, Poser speeds up, then your app may have something to do with Posers problems. If the answer is No, Poser is still slow, then it is more likely that Poser has some problems that only become apparent when another app starts up. Then I would suggest that you try to see if any other programs affect Posers performance.
In either case I would ask the guy to try running some other applications with Poser, not including yours, to see if he can duplicate the problem.
How much memory does this guy have on his machine? How much RAM does poser recommend? Have you been able to duplicate the problem on your machine? Also, have you been to Posers website to see if they have reported any problems like this?
I am just guessing, but hopefully some of these questions will get your started down the right path.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I am wondering too if he just doesn't have enough system memory.
Does the disk thrash when both programs are running. (i.e. the disk like blinks a HELL of a lot.) If so, this could be cause by a lot of page faults.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Unfortunately the answer is yes and no. Below is the answer I got from him:
"A very, very good question. About half the time, Poser will "speed" up to
it's original self, and the rest of the time, it pokes along like a turtle
in molasses high in the Alps in February, as if P3dO was still open. I've
checked to see which processes were still running (nothing unusual) and have
even flushed memory caches (doesn't have any effect).
I have a third-party memory tracking program (a de-bugger, if you will) that
will tell me when a block of memory has been "captured" by a program and
that refuses to release it. It hasn't reported anything unusual."
About other application running, he said this only occured with mine. Although people seldom run many app with Poser.
He has 1 Gb SDRAM on his machine a dual P3 750 Mhz and enough disk space. This is way enough for Poser use. I know the Poser web site well and I'm sure they won't answer such a question because they can't.
Yes, you're guessing for me but it's good to have some backing. I'm affraid the only thing left is to pray for a W2K compilation to solve the problem. I really can't see from here what is wrong with just that machine.
Thank you for your much appreciated help
Yarp
|
|
|
|
|
Have him check the W2K event viewer and see if anything strange is in there. Maybe he has EDO memory and one of the sticks is starting to go bad. Guessing at this point.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Hi Tim, I will ask him about the page faults. I don't think he has EDO memory this is a recent machine but we will see.
I was thinking as you did he might not have enough memory - altough 1 Gb - but I was rather thinking about virtual memory. I had such an adventure on a 700 Mhz Vaio with WMe. The machine ran with 128 Mb RAM and the many applications launched at system startup got more than 100 for themselves.
Yarp
|
|
|
|
|
The answer is that no other programm slows down but Poser when P3dO is loaded and there is no page fault.
Yarp
|
|
|
|
|
Um... wow...
It really sounds like it has to be an interaction problem between the two programs then.
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
I'm affraid. But I really can't see which one. I was also thinking about a shared .dll.
I'll try recompiling, some functions (like fopen) need to be recompile to run properly under NT. We'll see if this is enough.
Yarp
|
|
|
|
|
I need to display a bitmap without a windows frame. I've seen code here at the code project that can do this but can't find it again.
Del
|
|
|
|
|
Use the sample of splasj Screen. That will teach you how to do that...
If you don't find that sample, only add in a simple project, the componnet of splash screen, that you can find in the component gallery, and you will can see the class that make that....;)
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Does anyone know how to catch the EXIT when you exit or when you push the small x on the caption before it exits the program. I would like to in some instances not exit and would like to know where then I can add my code to do this.
THanks for the help.
|
|
|
|
|
one way is add WindowProc to your application, and check if ( message == WM_CLOSE ).
|
|
|
|
|
You can also check the WM_SYSCOMMAND message, with the SC_CLOSE value set in the wParam parameter. This occurs before the WM_CLOSE message.
Build a man a fire, and he will be warm for a day Light a man on fire, and he will be warm for the rest of his life!
|
|
|
|
|
I've got an MFC app that uses pattern brushes to display a background within dialogs. There seems to be different behavior between Windows 2000 and XP regarding the brush origin . The brush is set in the WM_CTLCOLOR handler OnCtlColor as follows:
<nobr><br />
CPoint origin(0,0);<br />
pDC->SetBkMode(TRANSPARENT);<br />
UnrealizeObject((HBRUSH)_BackgroundBrush);<br />
CRect rect;<br />
if (GetStyle() & WS_CHILD) {<br />
GetParent()->GetWindowRect(&rect);<br />
}<br />
else {<br />
GetWindowRect(&rect);<br />
}<br />
origin = rect.TopLeft();<br />
pWnd->ScreenToClient(&origin);<br />
pDC->SetBrushOrg(origin.x,origin.y);<br />
hbr = (HBRUSH)_BackgroundBrush;<br />
</nobr>
_BackgroundBrush is initialized elsewhere. This code is used in two dialogs; a main dialog, and then a second dialog that is 'embedded' within the main (it has the WS_CHILD style).
The problem I'm having is this. On Windows XP, the brushes all line up, and the bitmap pattern looks seemless across both the main dialog and the embedded one. On 2000, button controls (including group boxes) and statics do not align correctly . Supposedly Windows NT and its successors align brushes automatically, but I've found that they don't always do it correctly.
Any help would be much appreciated.
Gary Wheeler
|
|
|
|
|
I'm not sure if we have a place to post WTL questions yet or not, but has anyone used what ships with VS.NET? The wizard generated query asserts at Allocate.cpp (line 247) when I click the File menu Is anyone here using that could help me?
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|
WTL doesn't ship with VS.NET.
But the best place to ask WTL questions is:
Yahoo WTL group
Tim Smith
I know what you're thinking punk, you're thinking did he spell check this document? Well, to tell you the truth I kinda forgot myself in all this excitement. But being this here's CodeProject, the most powerful forums in the world and would blow your head clean off, you've got to ask yourself one question, Do I feel lucky? Well do ya punk?
|
|
|
|
|
Well don't I feel stooooopid. I had downloaded the WTL so long ago and installed the Wizard that when I looked at the wizards, I got excited thinking that they were finally shipping it with VS.NET.
In that case, I'm probably just out of date and need to update to WTL 7.
Thanks Tim!
Cheers,
Tom Archer
Author, Inside C#
Please note that the opinions expressed in this correspondence do not necessarily reflect the views of the author.
|
|
|
|
|