|
What is fPic? That's a pretty crucial bit of missing data...
How is the file opened?
Could it be failing on the opening (ie, already open elsewhere) and you're not handling the errors from a failed opening?
Iain.
I have now moved to Sweden for love (awwww).
|
|
|
|
|
struct CONFIGFILE_RECORD
{
char strPath[MAX_PATH];
char nStyle[2];
};
struct CONFIGFILE_HEADER
{
char bHasPic[2];
char bOrder[2];
char nTime[5];
char bEffect[2];
char nNum[3];
char nPos[3];
};
BOOL CCfgFile::loadConfigFile()
{
BOOL ret = FALSE;
char dir[MAX_PATH];
::GetCurrentDirectory( MAX_PATH, dir );
strcat( dir, "\\config" );
UINT mode = CFile::modeCreate | CFile::modeNoTruncate | CFile::modeReadWrite | CFile::shareDenyNone;
if( fPic.m_hFile )
fPic.Close();
ret = fPic.Open( dir, mode );
if( !fPic.GetLength() )
{
strcpy( hd.bHasPic, _T("0") );
strcpy( hd.bOrder, _T("1") );
strcpy( hd.nTime, _T("9999") );
strcpy( hd.bEffect, _T("0") );
strcpy( hd.nNum, _T("0") );
strcpy( hd.nPos, _T("0") );
fPic.Write( &hd, sizeof( CONFIGFILE_HEADER ) );
}
return ret;
}
|
|
|
|
|
You're first writing a CONFIGFILE_HEADER record to the file, rewinding it, and then writing one or more CONFIGFILE_RECORD records to it. Is that the intent?
Krauze wrote: // get the current dir
char dir[MAX_PATH];
::GetCurrentDirectory( MAX_PATH, dir );
strcat( dir, "\\config" );
This will not always result in the same path.
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Your ret is set to false and the return value from the file open is returned but never used in your main function.
|
|
|
|
|
Thank y'all! I've got it solved with the help of DavidCrow. Actually, ::GetCurrentDirectory() may return inconsistent paths.
|
|
|
|
|
I am making a desktop development.But there is a problem that I can't solve till now.In the development I have to add some command buttons to the listbox.And the first item is different from others.It is like a header with text.So how can I do it.Thanks.
|
|
|
|
|
Just try with the subclassing, You have subclass a control to get the rid, try this example Control Subclassing[^]
Величие не Бога может быть недооценена.
|
|
|
|
|
Thanks your help.Now I have solved the problem.
|
|
|
|
|
Hi all--
I've got a program where you click and add points to make a polygon using a linked list, and now I want it where by pressing a button it will take the points on the polygon and make it a cubic b spline curve. However I have no experience with the b spline curves and am having trouble with were to start. So I was wondering if you would be able to help me with the pseudo code for this, using C so that I can better understand what I'm trying to do. Here is what I have come up with so far (which isn't much unfortunately):
Create a drawCurve function that traverses the linked list in order.
Take the first four points to draw the spline curve, then the next one over each time.
[insert how to do the math here (of which I am confused about)]
Use a state machine to implement. So pressing a button of my choice will change between the drawing polygon state and the draw curve state.
Thank you very much for your help.
|
|
|
|
|
Now, where's that 'homework' tag?
L u n a t i c F r i n g e
|
|
|
|
|
I'm not asking you to do it for me, I'm just trying to figure out where to start
|
|
|
|
|
Carl De Boor's book "A practical guide to splines" has pseudo code for what you want.
|
|
|
|
|
|
Buddys,
How to create database and manipulations on that databse by using sqlite databse. plz provide me solution.
iam trying to create with add CppSQLite3.h in my code, but its not working, getting some sqlite exception.
|
|
|
|
|
kirancgi wrote: plz provide me solution.
This is not possible in a forum; try reading some of the articles on databases.
kirancgi wrote: its not working, getting some sqlite exception.
We cannot guess what this could mean. Show your code where the exception occurs, and include the exact wording of the exception. Only then can anyone try and help to diagnose the problem.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
Richard MacCutchan wrote: Only then can anyone try and help to diagnose the problem.
Well, you're not much of a mindreader now are you?
"One man's wage rise is another man's price increase." - Harold Wilson
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
DavidCrow wrote: Well, you're not much of a mindreader now are you?
True, but at my age some talents start to fade.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
At 27, I've almost lost all the mind reading capabilities. So, you're out of question!
“Follow your bliss.” – Joseph Campbell
|
|
|
|
|
Truth to tell I lost mine when I was half your age.
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
I knew you were going to say that!
Ali
|
|
|
|
|
Alison P wrote: I knew you were going to say that!
Wow, spooky!
txtspeak is the realm of 9 year old children, not developers. Christian Graus
|
|
|
|
|
You should start with drugz then.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
|
I am currently working on a project for a class, and what I need to do is make a .txt file with a letter on the first line and two two-digit numbers on the second line, and have it write to another text file what the ASCII code for the letter and add and multiply the two numbers.
I've been able to get the code to compile, but it prints out strange numbers instead of what the answers should be. I've been told to initialize my variables, but when I set them to 0, thats all the program reads. So I get a file like, the ASCII is 0, and 0 + 0 = 0, and the like.
Here is the code. Please tell me where I am messing up!
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
ifstream inFile;
ofstream outFile;
char letter1;
double num1;
double num2;
inFile.open("input.txt");
outFile.open("answers.txt");
inFile >> letter1 >> num1 >> num2;
outFile << "The ASCII value of your character: " << letter1<< " is " << static_cast<int>(letter1) <
|
|
|
|
|
why are num1 and num2 declared as double ? I would try 'int' (looking at your input file example)..
int num1 = 0;
int num2 = 0;
what is that static_cast doing ? try
<< (int)letter1 << endl;
ok, thats old school these days, but Im an old f@rt, so it doesnt matter ... in the next two lines, bracket the operations so you get
<< (num1 + num2) << endl;
<< (num1 * num2) << endl;
the 'system(pause)' isnt doing much - you can step through your prog using F10 for example (if you're using MSVC) and look at the variable contents - or, sprinkle some 'cout' statments around to display things on the console/stdout instead of just to the file
ie
cout << "The Value of num1 is : " << num1 << endl;
|
|
|
|