|
I didn't explicity create any extra threads, so I'll say it's single-threaded.
|
|
|
|
|
Exactly what does filepath contain?
When running from Visual Studio, the current directory is the one containing the .sln and .vcproj files. If your filepath only contains the name ("myfile.txt"), then it must exist in that directory.
When you run outside of visual studio, the current directory is the one containing the .exe file (normally the debug or release directory) and the file would then have to exist in that folder.
It's best to specify a full path name ("c:\\mydocs\\mydata\\myfile.txt") to avoid these problems.
Hope that helps.
Karl - WK5M
PP-ASEL-IA (N43CS)
PGP Key: 0xDB02E193
PGP Key Fingerprint: 8F06 5A2E 2735 892B 821C 871A 0411 94EA DB02 E193
|
|
|
|
|
Thanks Karl. The filePath is the absolute path to the text file I'm accessing. Accessing the file doesn't seem to give issues both in debug and release. A section of the code checks for file failure:
if(!file.fail())
{
}
|
|
|
|
|
Good advice but I do not think that is the cause of the problem. If he was using file (the ifstream object) without first checking to see if it was valid (e.g., bad path), then an exception would be understandable.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Problem solved and in 3 ways!
1. The "Keep it Simple Stupid" Advice works! Instead of creating an array of MATERIAL i.e Material*, I simply created an array of Material, and accessed each Material by the . notation rather than the ->.
i.e.
g_ptrMaterials = new Material [g_numberOfRows];
Material mat;
mat.temperature = 200.00;
2. One can stuff the structures into a vector:
vector<Material> vctr;
Material mat;
mat.temperature = 200.00;
mat.density = bla bla;
vctr.push_back(mat);
3. Lastly I modified the initial code. I don't know why it works ...
MATERIAL* arrMaterial = new MATERIAL[g_numberOfRows];
g_ptrMaterial = &arrMaterial[0];
arrMaterial[i] = new Material;
Perhaps the problem was mixing the malloc and new allocators? I suspected the problem was with the memory allocation, when the compiler continuously indicated errors in xmemory, dbgheap, and what not. It wasn't a v e r y pleasant experience. Anyway, I went for the first option, but one can go for any of the 3 options I suppose, without any harm.
Thanks guys
|
|
|
|
|
hi.
i work in Microsoft Visual Studio 2008 . i working in C# enviroment and creat a website project.
i want open picture with open dialog .please tell me who i can load picture with open dialog?
i am beginner .
please explain step to step.
whether i need a componet as toolbar?
please help me.
i need help body.
thank you
|
|
|
|
|
You might want to ask your question here.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi!
Got Windows Vista Business as the os. Ran msdev.exe with compatibility mode for Windows 98 (with others it failed, some sketchy errors appeared).
I get this error : "The project directory no longer exists. Please choose a different directory" as i try to create a new project. The funny thing is, that I created a project earlier the day without any problems. So I tried to change directories, didn't help. Searched google for the problem - found out that "Run as administrator" should fix the problem.. it didn't.
Has anyone else run into that problem?
|
|
|
|
|
How do you measure the performance of your C++ perf-critical code ?
Are you relying on automatic profilers or do you resort, for particular reasons, to compile time methods ?
If today, profiling is still an issue to you, then I would announce to you the availablity of easy profiler at Code Project along with source code that you may give it a try for your needs.
URL :
Easy Profiler - Compile-time Profiler for Unmanaged C++[^]
Use the article-forum to raise any issue and I will be glad to help.
Easy Profiler : Now open source !
http://www.codeproject.com/KB/cpp/easyprofiler.aspx
|
|
|
|
|
hi every body........
this is eswar....
i have a small doubt about barcode genaration.
is it possible to generate barcode application using vc++6.0
thanks in advance.....
|
|
|
|
|
This might be a lame answer: Isn't barcodes just some kind of a font like this? Then I guess you could write the same code you usually use to draw text, but with the barcode font instead.
|
|
|
|
|
You mean you want an application that generates barcodes OR you want to genereate a "barcode application", which could both mean that it can create OR read barcodes (thorough some input device like a webcam, a scanner or a barcode reader connected to the comp). Both should be possible. To generate barcodes you can either use a barcode font as someone already suggested, or you can try to check out how barcodes work (there are loads of infoes about it on the net, Google is your friend...) and write your own method of generation, also there are some libraries i believe around the net for such a purpose. Reading barcodes thorough a webcam or such input device is a much more problematic task. Good luck.
> The problem with computers is that they do what you tell them to do and not what you want them to do. <
> Sometimes you just have to hate coding to do it well. <
modified on Wednesday, November 4, 2009 10:40 AM
|
|
|
|
|
If you couldn't use MFC integrated database-classes, and you had to create a simple application that communicated with a database, how would you do that?
Would you use for instance SOCI, and make your non-GUI classes in STL? I mean, not use CString, but std::string, and when the GUI needs it, convert the std::string to CString and vica-versa?
Or would you make all the classes in MFC and add some kind of extra database layer that converts the database-output from SOCI (which then would be a std::string for instance) and make it a CString for your business-object class and then pass that class to the GUI?
Please tell if I'm not explaining this well enough.
|
|
|
|
|
Jan Sommer wrote: ...how would you do that?
I would look here. I would also look to see if the database supported Automation.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Thanks for your reply David
I'm looking for something more concrete then ODBC - That's certainly what I'm going to use since the application is going to be cross platform (and the database is an MS SQL Server). But how would you create the classes responsible for holding the database-data which the UI uses?
|
|
|
|
|
Hello,
I have a problem in writing a program with C++. I have been studying C# and Java but C++ is a way different to me, so I need your help.
My task is to make program which: reads an input from a text box than returns the nubers from that input which has two digits and their sum is 9.
For example:
Input: 12 231 81 53 522 11 63
Output: 81 63
I need it a ssimple as possible so I could understand it.
Thank you in advance.
|
|
|
|
|
Well I'm no math mastermind, but I think a way to solve your problem would be something like this...
if(input > 9 && input < 100) { //if the input is above 9 and under 100 then we pretty sure only have 2 digits
int n;
n = input / 9;
if(n*9 == input) {
//The sum is 9
}
}
this only checks ONE input - you got to figure out a way to split the input by spaces and loop through it.
Again, I have no clue if this is the simplest solution, but it should work
|
|
|
|
|
we also might have a little problem with "int n;" because if "input / 9" gives decimals like 6.6, it will be converted to 7. so you might want to use a double there instead of int.
|
|
|
|
|
The first order of business would be to break the problem down into more manageable pieces. Rather than try to solve the overall problem at once, instead try and solve the individual pieces and the larger problem will solve itself.
Roughly:
Get input from an edit control
Tokenize that input
For each token, determine if it is 2 digits and if the sum of the digits is 9
If so, print that token
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"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
|
|
|
|
|
Hi All
How can i get MSSQL Installation path?There is any command Plz help me
|
|
|
|
|
What has this to do with C/C++/MFC?
|
|
|
|
|
Well, although he did not specify it but he might want to know the path programatically.
-Saurabh
|
|
|
|
|
Saurabh.Garg wrote: Well, although he did not specify it but he might want to know the path programatically.
-Saurabh
He might want to know the time in Timbuktoo ... It would help if people specified clearly what their problem is in the first instance.
|
|
|
|
|
Yes but that is the sad reality of programming forums. I have accepted the situation and stop fighting it. This way it is so much more easier.
-Saurabh
|
|
|
|
|