Hi, I have been working on some dll project, just to store values.
I hardly use arrays, so it may be a bit on the stupid side.
Ok, this is the program that uses the dll: - #include <iostream>
-
#include <conio.h>
-
#include <string>
-
#include <windows.h>
-
#include "..\dlltest1\main.h"
-
using namespace std;
-
int main()
-
{
-
dll store;
-
store.store("hello");
-
char *vals = store.getvals(1);
-
for (int i = 0; i <= 10; i++) cout << " " << vals[i] << "\n";
-
return 0;
-
}
dll header: - #ifdef DLLDIR_EX
-
#define DLLDIR __declspec(dllexport) // export DLL information
-
-
#else
-
#define DLLDIR __declspec(dllimport) // import DLL information
-
-
#endif
-
-
using namespace std;
-
class dll
-
{
-
private:
-
char storagearray[1000][10][1000];
-
static int ammount;
-
-
public:
-
dll();
-
~dll();
-
int addto(string string, int loc);
-
int store(string string, int loc = 0);
-
int add(string thing);
-
char* getvals(int loc);
-
};
and dll main: - #include <string>
-
#include "main.h"
-
#include <iostream>
-
-
-
using namespace std;
-
-
dll::dll(){};
-
dll::~dll(){};
-
-
int dll::ammount = 1;
-
-
int dll::addto(string string, int loc){
-
if(storagearray[loc][0][0]){
-
int x = 2+ storagearray[loc][1][0];
-
if(x<8){
-
strcpy(storagearray[loc][x],string.c_str());
-
storagearray[loc][1][0] = ++x;
-
return 0;
-
}
-
else return 3;
-
}
-
else return 2;
-
}
-
-
int dll::add(string string){
-
for(int i = 1; i <= ammount; i++){
-
if(storagearray[i][0][0]) continue;
-
else { storagearray[i][0][0] = 1;
-
int thing = 2+ storagearray[i][1][0]++;
-
strcpy(storagearray[i][thing],string.c_str());
-
return 1;
-
}
-
ammount++;
-
storagearray[ammount][0][1]++;
-
strcpy(storagearray[ammount][2],string.c_str());
-
storagearray[ammount][0][0] = 1;
-
cout << (char)string.c_str() << " added. \n";
-
return 1;
-
-
}
-
return -1;
-
}
-
-
int dll::store(string string, int loc){
-
int done = 0;
-
int dloc = 0;
-
if(loc == 0) dloc = add(string);
-
else done = addto(string, loc);
-
if(dloc == -1) return 5;
-
else return done;
-
}
-
-
char * dll::getvals(int loc){
-
char *array;
-
if(storagearray[loc][0][0]){
-
for(int i = 0; i <= 10; i++){
-
strcpy(array, storagearray[loc][i]);
-
}
-
}
-
return array;
-
}
-
-
-
The return value for this is : -1073741571 (0xC00000FD)
It is using the correct object file.
I cant see what the problem is exactly, when building the dll, theres no output errors. But i do have doubts about 'storagearray'.
2 1360
What exactly are you trying to do?
A class named dll is very od since an object ios not a dll. Are you trying to create a dll and use it?
I see you mixing C++ strings (string() with C-srrings (char*). Why can't yu use just string objects?
There is a 3D array in your class. C++ programmers generally use a vector instead of an array. Why 3D? If you are attempting to store strings you would have a vector<vector<string> > so I don't see where the third dimiension comes in.
Also that 3D array is very large and is on the stack. Stack memory is not the place for things like this. Again, all this is resolved by using a vector since a vector manages its own memory.
I was having trouble storing a string in, say, [1][2] - so I assumed that the array was only holding a single value.
so then I used [1][2][1000], and i would copy and string into [1][2], copying the string into [1][2][0-1000], then the crashing came in...
Im making a dll to store stuff (for no reason) .
When I used 2d arrays, they stored values.. wrong, like corrupted.
The translation was working fine (string -> char, char -> string).
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Joseph |
last post by:
Hi
I'm writing a commercial program which must be reliable. It has to do
some basic reading and writing to and from files on the hard disk,
and also to a floppy.
I have foreseen a potential...
|
by: Eric Brunel |
last post by:
Hi all,
I was creating a Tkinter widget in the style of the reversed tabs below Excel
worksheets and I stepped in a serious problem: the code I made makes python
crash with a seg fault, bus...
|
by: Adam Louis |
last post by:
I would like help resolving this problem. I'm a novice who's been
hired to query a hospital database and extract useful information,
available to me only in a dynamically generated, downloadable...
|
by: JK Peck |
last post by:
I have a fairly large Access application that ran correctly in Access
2000. After upgrading to Access 2003 (and recompiling and updating
references), it reliably crashes at a certain point. If I...
|
by: Droopy |
last post by:
Hi,
I am running an application on 74 PC (1 instance on each PC).
This morning, 2 applications crashes.
There were neither popup windows signaling it nor dump file created.
I only find in the...
|
by: benjamin.krulewitch |
last post by:
I'm debugging an issue with a C program that causes the computer to
crash, and I'm attempting to log information immediately before the
crash occurs. I us my BKprintLog function (see below) to...
|
by: alf |
last post by:
Hi,
is it possible that due to OS crash or mysql itself crash or some e.g.
SCSI failure to lose all the data stored in the table (let's say million
of 1KB rows). In other words what is the worst...
|
by: linq936 |
last post by:
Hi,
It could be a very simple problem, but i can not see it...
Here is the code:
char* lower(char* str){
char* p = str;
while ( *str ) {
*str = tolower(*str); <=====crash!
str++;
|
by: Alex |
last post by:
Hello everybody,
I've been working for days on a "twilight zone" bug and I can't make any
sense of it. This is in an application that was developped on XP and that
was modified to handle Vista....
|
by: =?Utf-8?B?R2VyaGFyZA==?= |
last post by:
I have run into a situation that if a page/tab that uses the Ajax toolkit
(using .net version 3.5) is closed before the Ajax enable controls complete
loading, then IE locks up. Does it in both IE7...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |