|
HOW WHAT wrote: z:\windows\explorer.exe
Let me break every thing to simplify every thing for you
z: = PATH and Drive Name
Z:\Windows :- Path and Directory
Z:\Windows\explorer.exe :- path and Filename
Path can be any thing.. but it depends on what you are calling
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hello everyone!
Alright... Remember the questions about binary files I've been asking lately? Well, thanks to you, my program worked!
I converted the program to C (not C++), no problem... I added a file header at the beginning of file, no problem... but if I try to compile the program with the Digital Mars compiler, with the -mtd option (DOS .COM file), and I make a file with that program, the file comes out 10 bytes less than the Windows version! Therefore, the programs can't open each other's files! Anyone know of a solution? Thanks!
PS: In case you need the code to help me out, here it is: (233 lines)
http://sulfurmidis.com/peopledb.htm[^]
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
-- modified at 18:21 Sunday 12th February, 2006
|
|
|
|
|
Have you compared the 2 output files? If it's only 10 bytes, you should be able to find the differences easily
|
|
|
|
|
Well... based on the error messages I get, the headers are messed up... Why isn't there a native DOS version of GCC?! (One that doesn't need a cwdpmi server or whatever it's called...)
Anyways... I'll see what I'll do. Thanks!
Lord Kixdemp
www.SulfurMidis.com
www.SulfurSoft.tk
[ftp://][http://][hotline://]tsfc.ath.cx
|
|
|
|
|
int s are generally 16-bits in DOS, but 32-bits in Windows. If you want 32-bit, use a long . If you want 16-bits, use a short - these are meant to be guaranteed between different compilers.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
|
The C++ standard states that a long is 4 bytes and a short is 2 bytes. An int is defined by the size of the standard machine word for the architecture you're compiling for - 32 bits for Windows and 16-bits for DOS (unless you're using a 32-bit DOS extender such as DOS4GW).
Note that the size of a byte is not defined (other than to say it must be at least 8 bits), so a short may not actually be 16 bits, although I've never seen a situation where it is different.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
Yeah, longs in .NET are 64-bits by definition.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
|
Heya
I'm using DiLascia's CPictureCtrl in an MFC application, which works quite nicely. CPictureCtrl is essentially a wrapper around IPicture. Also, I use the gd library in my program. The dream of my sleepless nights would be to update the image displayed in the CPictureCtrl with text put into it through the gd functions. Hence, I'd need the picture to be stored in memory (which it is, inside the CPictureCtrl object) and then manipulate or replace it using gd. Any idea how to put those ends together?
Cheers
Robert
|
|
|
|
|
Hello,
Is it legal to 'delete' single elements of an array that was allocated all at once with 'new Array[Count]' ??
I want to allocate an array of stuff as in 'pArray = new Type[5];'
But I want to de-allocate each element one at a time as in:
for ( a = 0; a < Count; a ++ )
delete pArray[a];
It is giving me ASSERT failures in the C runtime, so I'm thinking that this may not be allowed.
Thanks,
Rich
|
|
|
|
|
What's your reason for wanting to do so?
|
|
|
|
|
Hi, thanks for your response. I was having a brain-lock.
Rich
|
|
|
|
|
You're allocating and deleting different things. So no, generally you can't do this.
But why would you want to do so anyway? Is your array an array of pointers? If so, make sure you do a new on each element of the array, as well as the whole array.
Ryan "Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
|
|
|
|
|
You're absolutely right. It is not an array of pointers, so when I say "delete Array[a];" I'm telling it to delete the actual instance, rather than the pointer to that instance.
So I wonder why it did not give me a compiler error?
Thanks so much,
Rich
|
|
|
|
|
Don't do that. If you need to construct/destruct individual objects, then a C-style array is the wrong thing to use.
If you could destruct individual members of an array, think what would happen when you later delete the array? The runtime will try to destruct the objects again.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | NEW!! PimpFish | CP SearchBar v3.0 | C++ Forum FAQ
|
|
|
|
|
Hi Mike,
Thank you for your response. I will have to redesign that part of the program to do it in a different way.
Rich
|
|
|
|
|
Troposphere wrote: for ( a = 0; a < Count; a ++ ) delete pArray[a];
You don't need to delete Individual memory...
you can simply delete all memory allocated to the array in one go :-
delete [] pArray
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
|
|
|
|
|
Hi all
I am having a problem with opening file for the second time. Below is the function that I wrote.
- cpHeader returns a portion of a string taken from the file
example: the file contains string "abcdefghi jklmn opqrstuvwxyz"
after some manipulations, cpHeader returns "n opqrstuvwxyz" (char*)
- cpTemp is supposedly taking in the rest of the string to process it further.
However, for the time being, it is only a dummy function, doing nothing
The problem occurs after I read a file once. Then, if I want to read another file (either it's the same or different), fileptr always returns NULL. And I received error message as "efghi jklmn opqrstuvwxyz" (not "File open error") . I can't think of any possible reason why this error occur. Or, what is the relationship between the string manipulations and the fopen operation?
It would be very great if anybody could help me with this matter. Thanks!
void convertAndPost(AnsiString filename)
{
FILE *fileptr = NULL;
char *file = filename.c_str();
fileptr = fopen(file, "rt");
if(fileptr == NULL)
{
MessageBox(NULL,"File Open Error",NULL,0);
exit(0);
}
else
{
char* start = cpHeader(fileptr);
cpTemp(start, fileptr);
}
fclose(fileptr);
}
- Sharing information is the best way to advance together -
|
|
|
|
|
kittymew wrote: And I received error message as "efghi jklmn opqrstuvwxyz" (not "File open error") . I can't think of any possible reason why this error occur. Or, what is the relationship between the string manipulations and the fopen operation?
This clearly means, that cpTemp is still involved in the file operations, and you have already returned from the method and close the file pointer even before the file operations have been completed, check out the code in cpTemp, are you returning the command back to convertAdnpost() before the file operations have been completed?
|
|
|
|
|
I have it broken into 3 source files, here is the code:
#include "cstring"<br />
#include "hugeint.h"<br />
<br />
HugeInt::HugeInt( long val )<br />
{<br />
int i; <br />
<br />
for ( i = 0; i <= 29; i++ )<br />
integer [i] = 0;
<br />
for ( i = 29; val != 0 && i >= 0; i-- ) <br />
{<br />
integer[i] = val % 10;<br />
val /= 10;<br />
}<br />
}<br />
HugeInt::HugeInt( char *string )<br />
{<br />
int i, j;<br />
<br />
for ( i = 0; i <= 29; i++ )<br />
integer[i] = 0;<br />
<br />
for ( i = 30 - strlen( string ), j = 0; i <= 29; i++, j++ )<br />
if (isdigit( string[j] ))<br />
integer[i] = string[j] - '0';<br />
}<br />
HugeInt HugeInt::operator+( HugeInt &op2 )<br />
{<br />
HugeInt temp;<br />
int carry = 0;<br />
<br />
for ( int i = 29; i >= 0; i-- ) <br />
{<br />
temp.integer[i] = integer[i] + <br />
op2.integer[i] + carry;<br />
<br />
if ( temp.integer[i] > 9 ) {<br />
temp.integer[i] %= 10;<br />
carry = 1;<br />
}<br />
else<br />
carry = 0;<br />
}<br />
<br />
return temp;<br />
}<br />
HugeInt HugeInt::operator+( int op2 )<br />
{ return *this + HugeInt( op2 ); }<br />
<br />
HugeInt HugeInt::operator+( char *op2 )<br />
{ return *this + HugeInt( op2 ); }<br />
<br />
ofstream& operator << ( ofstream &output, HugeInt &num )<br />
{<br />
int i;<br />
<br />
for ( i = 0; ( num.integer[i] == 0 ) && ( i <= 29 ); i++ );
if ( i == 30 )<br />
output << 0;<br />
else<br />
for ( ; i <= 29; i++ )<br />
output << num.integer[i];<br />
<br />
return output;<br />
}<br />
<br />
#include <iostream><br />
<br />
using namespace std;<br />
<br />
class HugeInt {<br />
<br />
public:<br />
short integer[30];<br />
HugeInt();
HugeInt( long int );
HugeInt( const char * );
HugeInt operator+( HugeInt );
void operator=( HugeInt );
void print( ofstream& );
};<br />
<br />
#include <fstream>
#include "hugeint.h"<br />
<br />
using namespace std;<br />
<br />
int main()<br />
{<br />
HugeInt n1(7654321), n2(7891234),<br />
n3("99999999999999999999999999999"), n4("1"), n5;<br />
<br />
fstream fout;<br />
fout.open("file.txt");<br />
<br />
fout << "n1 is ";<br />
n1.print(fout);<br />
fout << endl;<br />
fout << "n2 is ";<br />
n2.print(fout);<br />
fout << endl;<br />
fout << "n3 is ";<br />
n3.print(fout);<br />
fout << endl;<br />
fout << "n4 is ";<br />
n4.print(fout);<br />
fout << endl;<br />
fout << "n5 is ";<br />
n5.print(fout);<br />
fout << endl;<br />
<br />
n5 = n1 + n2;<br />
n1.print(fout);<br />
fout << " + ";<br />
n2.print(fout);<br />
fout << " = ";<br />
n5.print(fout);<br />
fout << endl << endl;<br />
<br />
n5 = n3 + n4;<br />
n3.print(fout);<br />
fout << " + ";<br />
n4.print(fout);<br />
fout << " = ";<br />
n5.print(fout);<br />
fout << endl << endl;<br />
<br />
n5 = n1 + 9;<br />
n1.print(fout);<br />
fout << " + " << 9 << " = ";<br />
n5.print(fout);<br />
fout << endl; << endl;<br />
<br />
n5 = n2 + "10000";<br />
n2.print(fout);<br />
fout << " + " << "10000" << " = ";<br />
n5.print(fout);<br />
fout << endl << endl;<br />
<br />
fout.close();<br />
return 0;<br />
} <br />
<br />
My main error is 'HugeInt::print' : cannot convert parameter 1 from 'std::fstream' to 'std::ofsteam &'
but there may be more errors than this. Thanks for any help you could give!
-- modified at 14:41 Sunday 12th February, 2006
|
|
|
|
|
HugeInt::print(..) code is missing?!
|
|
|
|
|
hmmm that does make sense... I dont even have a HugeInt::print why would it give me an error pertaining to that? Only thing I have about print is void print(&ofstream);
Thanks for the reply, still need help
|
|
|
|