|
Ah!
I found my critical mistake. Yes, the byte-alignment would be an issue and I did account for this as my binary file read is based on a similar operation I performed successfully in the same application.
MY PROBLEM WAS in how I opened the file. I orginally was reading a text file and then when I changed to reading a binary file, I forgot to use the parameter in the fopen() statement:
fopen (sSourceFile,"rb") instead of just fopen (sSourceFile,"r")
Thanks for all those who offered help and advice.
Johnny
|
|
|
|
|
Hello,
What would be the easiest way to extract just a file name from a CString containing a full path and file name?.. I realize there are other ways of getting the file name besides parsing the string but for right now I need to extract the info from a string..
eg..
CString strPath;
strPath = "c:\\some path\\that could be deep\\this is\\file.txt";
What would be the best way to extract the "file.txt"? The problem I am having is the file is not all ways the same name and the path varies in length(depending where the file is located."
Thanks,
Rob
Rob Jones
|
|
|
|
|
You may have got the answer already, but here is what I would offer:
pos = strPath.ReverseFind('\\') and
strPath.Right(pos)
It would be proper to test if strPath actually is in the format you expect, i.e. DriveName:\...\filename.extension
a slick routine would except:
c:\filename.ext
c:\dir1\filename.ext
filename.ext
Good luck.
|
|
|
|
|
Take a look at the MFC routine AfxGetFileName. You probably can't use it directly, but you can lift the code and use it in your app.
Tim Smith
Descartes Systems Sciences, Inc.
|
|
|
|
|
You can USe _splitpath
Or if you want to use only MFC and CString
I will do this
strPath = "c:\\some path\\that could be deep\\this is\\file.txt";
strPath.MakeReverse();
strFileName = strPath.Rigth(strPath.Find('\\'));
strFileName.MakeReverse();
test because I wrote directly over CP....
Best Regards....
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
|
Use PathFindFileName() from shlwapi.dll.
--Mike--
http://home.inreach.com/mdunn/
While I can't be correct on all matters, I can make the reassuring claim that where I am inaccurate, I am at least definitively inaccurate.
your with and
Sonork - 100.10414 AcidHelm
|
|
|
|
|
Hi all!
I have enums defined in groups as shown below:
typedef enum myType
{
TYPE_UNKNOWN = 0,
// 1 - 19
TYPE_START = 1,
TYPE_OK,
// 20 - 99
TYPE_ERROR=20,
TYPE_BADDATA,
TYPE_BLAH
// 100 -- 199
TYPE_HELP1=100,
TYPE_HELP2,
TYPE_HELP3
}myType;
I want to use the switch statement which could break the above into certain range they fall in, instead of doing:
switch( nMyType )
{
case TYPE_UNKNOWN:
break;
case TYPE_START:
break;
case TYPE_ERROR:
case TYPE_BADDATA: // I dont want to list each and every case
// b'cause i will be having a lot of them at some point
break;
default:
break;
};
Rather, I am looking for something like:
switch( nMyType )
{
case TYPE_START to TYPE_OK: // ie. 1-19
// I will be calling appropriate routines to handle the explicit
// case
break;
case TYPE_ERROR to TYPE_BLAH:
break;
default:
break;
};
Currently I have a IF else condition for the above ranges, Just wondering can I have the range in a switch statement?
I'll appreciate any hint/help!
thx
kpsr
|
|
|
|
|
switch(n)
{
case 0:
DoSomething();
break
case 1:
case 2:
case 3:
case 4:
DoSomething2();
break;
}
Best Regards
and for ever in CP
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Carlos,
Didn't really solve my purpose.
As I said in my earlier message, I do not want to list out individual cases, since there will be a lot.
I want to get a range like,
if( n > 1 || n < 10 )
DoSomething(n);
else if( n > 10 || n < 200 )
DoSomething2(n);
else if( n > 200 || n < 300 )
DoSomething3(n);
else
DoSomething4(n);
But, was wondering If I could do it using the switch statement by any means?.
thx
kpsr
|
|
|
|
|
You don't have condition in a Switch case. Only have values in the case...
The best is use
if(condition0)
{
}
else if(condition1)
{
}
else
{
}
I'm sorry...
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
How can i get the names of all files in a specific folder? (in other words, how can i see what files are in a folder) (possibly with a filter to view only one type?)
P.S.: it has to be some sort of function that will return me the strings or give me a list or something, i'm not looking for the common open file dialog here
Greats n kisses
Kuniva
|
|
|
|
|
|
Using the Class CFindFile
Best Regards
Carlos Antollini.
Sonork ID 100.10529 cantollini
|
|
|
|
|
Would anyone recommend a site/book that is really well written to introduce MFC in Visual C++(i.e. - basic intoduction leading to the more advanced)? I have knowledge of C++, however, the articles written on this site are more directly related to the use of MFC once you have a good understanding of them. Thanks again.
Nick Parker
|
|
|
|
|
|
Advanced programmer
MFC Internals (Stepherd Wingo)
Best books in explaining MFC.
As for beginner, check out amazon.com.
Do check the rating. It really helps.
|
|
|
|
|
I 100% recommend Kruglinski: Inside Visual C++ version 4.
It's about VC 4.0 but still valid for the majority of the field. Don't know if there is any new editions of it.
And for non-MFC windows programming, which is very usefull even though you use MFC:
Petzold: Programming Windows 95 (maybe there's a new version here too)
Richter: Advanced Windows
Cheers
Steen.
"To claim that computer games influence children is rediculous. If Pacman had influenced children born in the 80'ies we would see a lot of youngsters running around in dark rooms eating pills while listening to monotonous music"
|
|
|
|
|
Hello,
I just developed a CWnd derived class.
I include this Wnd in a DialogBox.
I'm able to handle the On<r l="" m="">Button<down up="">, but when I add the OnMouseWheel, the function is not send the my CWnd-derived class.
Any clue ? Do I forgot something ?
Thanks,
Stephane
"It is ridiculous to claim that video games influence children.
For instance, if PacMan affected kids born in the eighties, we
should by now have a bunch of teenagers who run around in darkened
rooms eating pills while listening to monotonous electronic music."
|
|
|
|
|
I'm on W2k SP2 VCPP6.0 SP ( the last one )
"It is ridiculous to claim that video games influence children.
For instance, if PacMan affected kids born in the eighties, we
should by now have a bunch of teenagers who run around in darkened
rooms eating pills while listening to monotonous electronic music."
|
|
|
|
|
Hi,
I would like to do in Windows-based with Visual C++ the following command:
Convert.exe file1.dat file2.txt
The above is in DOS Command line. I wonder how to do in MFC.
I have explore CreateProcess(),ShellExecute, WinExec,Spawn etc, in vain...! please help...!
Thanks,
/Sophal
|
|
|
|
|
ShellExecute(NULL,"open","C:\\convert.exe","file1.dat file2.txt",
"",SW_SHOW);
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hi,
I would like to do in Windows-based with Visual C++ the following command:
Convert.exe file1.dat file2.txt
The above is in DOS Command line. I wonder how to do in MFC.
Thanks,
/Sophal
|
|
|
|
|
Two identical posts except for that one extra line in the other post.
Maybe you should have modified this one instead of re-posting jus to add a line. Or you could have replied to your own post, addin the new line.
a new thread jus to add a line to the old thread is .... well,......
Nish
Sonork ID 100.9786 voidmain
www.busterboy.org
Nish is a BIG fan of Goran Ivanisevic
|
|
|
|
|
Hi!
const int TOTAL_LEN = 8;
CString lBuffer;
lBuffer.Format("%8s","hello");
// I want to use the macro (TOTAL_LEN) instead of hardcoding '8'
// in the Format of the String
// something like
lBuffer.Format("%TOTAL_LENs","hello");
// obviously the above would result as "TOTAL_LENs" and not " hello"
// basically I want to insert spaces using the constants
// and without using the for loop
// CAN I DO IT or do I have to stick with the for loop
|
|
|
|