|
You posted this question 17 minutes ago.
Maxwell Chen
|
|
|
|
|
If you are not able to see the post on this page please go to the next page or check your posts for the response. The people here are to help each other and sometimes reading through the same question can cause frustration to creep in . Please keep a track of the posts that you make and quote properly what you are willing to ask and discuss.
Vision is Always important and so is your ATTITUDE.
Wishes.
Anshuman Dandekar
|
|
|
|
|
Hi,
Is there a function for determining the size in bytes of an embedded resource?
My program needs to use LoadResource to load resources on the fly, and it would really help if it could tell the size of the resource it has loaded.
Thanks,
Rich
ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸
|
|
|
|
|
|
Thanks, Steve.
ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸¸,ø¤º°`°º¤ø,¸
|
|
|
|
|
How to read .PST file using VC++?
What is the structure to read .PST files using Files.
knarasimharao
|
|
|
|
|
What are PST files ?
You can perhaps find the file format by googling (I didn't find it on http://www.wotsit.org[^])
|
|
|
|
|
I guess he's talking about MSOutlook Personal folders.
<marquee scrollamount="1" scrolldelay="1" direction="up" height="10" step="1">--[V]--
[My Current Status]
|
|
|
|
|
|
Hi,
I am asking the file structure for reading .PST files. Becuase I have to open .PST files using File Handling in VC++ in binary mode, and I have to read the messages and display on the correcsponding Rich Edit Control. If you know the structure of .PST file, that helps alot to me. Because structure contains the size of each column like sender name, receivers name, message and so on.
knarasimharao
|
|
|
|
|
This program is going fairly smoothly, only problem being that it keeps blowing up at the point where I try to copy my current dynamic array to a temporary one. I'm sure it's a frivolous error, but I just can't seem to locate it. Spent the past 30 minutes staring at it to no avail. Anyone who cares to take a couple minutes to look over it, it would be incredibly helpful. Thanks!
Header File :
#include <iostream>
using namespace std;
int i;
class Array
{
private:
int element;
int *array;
bool extend();
bool contract();
public:
Array( );
Array(int array);
Array(int array, int elem);
~Array() {}
bool append();
bool chop();
bool print();
bool success;
};
Array :: Array ( )
{
int *array = 0;
}
Array::Array (int elem)
{
int *array = 0;
element = elem;
array = new int[element];
for (i=0; i<element; i++)
{
cout << "Please enter element "<< i << " : " << endl;
cin >> array[i];
}
}
bool Array :: append()
{
success = false;
success = extend();
if (success = true)
return (true);
else
return (false);
}
bool Array:: extend()
{
element += 1;
int* temp = 0;
temp = new int[element];
for (i=0; i<element; i++){
temp[i] = array[i];
}
cout << "Enter new element value : " << endl;
cin >> temp[element];
delete [] array;
array = temp;
return (true);
}
bool Array :: chop()
{
success = false;
success = contract();
if (success = true)
return (true);
else
return (false);
}
bool Array :: contract()
{
element -= 1;
int* temp2 = NULL;
temp2 = new int[element];
for (i=0; i<element; i++){
temp2[i] = array[i];
}
delete [] array;
array = temp2;
return (true);
}
bool Array :: print()
{
for (i = 0; i < element; i++)
{
cout << "The value of element " << i << " is " << array[i] << endl;
}
return (true);
}
Main File (not really necessary with this I'm sure)
#include <iostream>
#include "class.h"
using namespace std;
void main()
{
int n;
int elem;
bool completion = false;
cout << "Enter desired array size : " << endl;
cin >> elem;
Array ar1(elem);
completion = ar1.append();
if (completion == true)
{
cout << "Append successful!" << endl;
}
else
{
cout << "Append Unsuccessful!!" << endl;
}
completion = false;
completion = ar1.chop();
if (completion == true)
{
cout << "Chop successful!" << endl;
}
else
{
cout << "Chop Unsuccessful!!" << endl;
}
completion = false;
completion = ar1.print();
if (completion == true)
{
cout << "Print successful!" << endl;
}
else
{
cout << "Print Unsuccessful!!" << endl;
}
completion = false;
system ("pause");
}
Please forgive my newbishness
|
|
|
|
|
Can you tell in which function exactly the program crashes ? Also, use the '<' tag otherwise these symbols are not visible (or check the Ignore HTML tags button).
Now, a suggestion: in your constructors you are declaring a local variable array, is this the intent ?
Array::Array (int elem)<br />
{ <br />
int *array = 0; <br />
element = elem; <br />
array = new int[element]; <br />
for (i=0; i<element;i++)<br />
{ <br />
cout << "Please enter element "<< i << " : " << endl; <br />
cin >> array[i]; <br />
}<br />
}
This will have no effect on your member variable array (because it is redeclared locally). You have to remove the int* in front of array
|
|
|
|
|
Well, that does solve one of my issues, thanks much. The new one that arises is within
bool Array:: extend()<br />
{<br />
element += 1;<br />
temp = new int[element];<br />
for (i=0; i<element; i++){<br />
temp[i] = array[i];<br />
}<br />
cout << "Enter new element value : " << endl;<br />
cin >> temp[element];<br />
delete [] array;<br />
array = new int[element];<br />
for (i=0; i<element; i++){<br />
array[i] = temp[i];<br />
}<br />
delete [] temp;<br />
*temp = NULL;<br />
return (true);<br />
}
I can enter the new element value and then it blows up.
|
|
|
|
|
Please use the < tag when you need to display such characters, the most important part of your code (in this case) is unreadable.
But I guess (because some parts are missing), that you are writing outside the bounds of the array:
cin >> temp[element];
element is outside the bounds (remember that C and C++ use zero-indexed arrays, so element-1 is the last element of your array).
|
|
|
|
|
Ack, simple error....of course. Alrighty, now that *that* is taken care of, I've got yet another error. Gonna get it focused before I post it.
|
|
|
|
|
Revised code is as follows then
Header File :
#include <iostream>
using namespace std;
int i;
class Array
{
private:
int element;
int *array;
bool extend();
bool contract();
public:
int *temp;
int *temp2;
Array( );
Array(int array);
Array(int array, int elem);
~Array() {}
bool append();
bool chop();
bool print();
bool success;
};
/* Default Constructor
-Pre none
-Post *array set to 0
*/
Array :: Array ( )
{
int *array = 0;
}
/* Secondary Constructor
Initializes Dynamic Array
-Pre int elem set to a value
-Post *array set to dynamic array
*/
Array::Array (int elem)
{
element = elem;
array = new int[element];
for (i=0; i<element; i++)
{
cout << "Please enter element "<< i << " : " << endl;
cin >> array[i];
}
}
bool Array :: append()
{
success = false;
success = extend();
if (success = true)
return (true);
else
return (false);
}
bool Array:: extend()
{
element += 1;
temp = new int[element];
for (i=0; i<element; i++){
temp[i] = array[i];
}
cout << "Enter new element value : " << endl;
cin >> temp[element-1];
delete [] array;
array = new int[element];
for (i=0; i<element; i++){
array[i] = temp[i];
}
delete [] temp;
*temp = NULL;
return (true);
}
bool Array :: chop()
{
success = false;
success = contract();
if (success = true)
return (true);
else
return (false);
}
bool Array :: contract()
{
element -= 1;
temp2 = new int[element];
for (i=0; i<element; i++){
temp2[i] = array[i];
}
delete [] array;
array = new int[element];
for (i=0; i<element; i++){
array[i] = temp2[i];
}
delete [] temp2;
*temp2 = NULL;
return (true);
}
bool Array :: print()
{
for (i = 0; i < element; i++)
{
cout << "The value of element " << i << " is " << array[i] << endl;
}
return (true);
}
Main
#include <iostream>
#include "class.h"
using namespace std;
void main()
{
int n;
int elem;
bool completion = false;
cout << "Enter desired array size : " << endl;
cin >> elem;
Array ar1(elem);
completion = ar1.append();
if (completion == true)
{
cout << "Append successful!" << endl;
}
else
{
cout << "Append Unsuccessful!!" << endl;
}
completion = false;
completion = ar1.chop();
if (completion == true)
{
cout << "Chop successful!" << endl;
}
else
{
cout << "Chop Unsuccessful!!" << endl;
}
completion = false;
completion = ar1.print();
if (completion == true)
{
cout << "Print successful!" << endl;
}
else
{
cout << "Print Unsuccessful!!" << endl;
}
completion = false;
system ("pause");
}
I unfortunately get an access violation error, but if I force the debugger to continue, the program works. Which, is nice to know, but I still need to fix it
|
|
|
|
|
Use your debugger (F5 key) to locate the problem. You can put breakpoints in your code with F9 key. This is very usefull to watch your variables.
|
|
|
|
|
bool Array :: contract()
{
element -= 1;
temp2 = new int[element];
for (i=0; i<element; i++){
temp2[i] = array[i];
}
delete [] array;
array = new int[element];
for (i=0; i<element; i++){
array[i] = temp2[i];
}
delete [] temp2;
*temp2 = NULL;
return (true);
}
There's an access violation somewhere in the midst of this fun. Element is being properly decremented before its use with temp in creating the new array; in the assignment for loop, it will not go beyond the scope because element is the size of the smallest array. Everything seems pretty clear.
|
|
|
|
|
Well, I'm going to call it a night. If anyone has any further insight, I'll be back on in about six and a half hours to take a look. Peace.
|
|
|
|
|
JarethAshaer wrote: *temp2 = NULL;
This is wrong: you deleted temp2 so the memory has been freed. Then you try to write NULL in the 'variable' pointed by temp2. Remove the '*': you will write NULL in the pointer, not in the variable pointed by temp2.
|
|
|
|
|
Good thing I checked one last time before I called it a night! That fixed it! Thanks much
|
|
|
|
|
JarethAshaer wrote: Array :: Array ( )
{
int *array = 0;
}
I assume you mean this:
array = 0;
What you had does nothing. It sets a local pointer to zero which then goes out of scope.
Steve
-- modified at 3:26 Friday 5th May, 2006
|
|
|
|
|
Aye, took care of that along with Cedric's suggestion. Thanks though!
|
|
|
|
|
Yes sorry, that wasn't very clear: I said the constructors (so which means both of them ). But I agree, I should have been more explicit
|
|
|
|
|
What is the API to get the Current folder path where the application resides?
Thanks in advance.
Rinu
|
|
|
|