|
missing LVS_EX_FULLROWSELECT style ?
|
|
|
|
|
|
Hello everybody,
how to allocate multi-dimensional pointer in c and c++?
what i mean by multi-dimensional pointer is: for example char**, or long***
<br />
Here is what i did. but i does not allocate memory properly.<br />
....<br />
char ** pString;<br />
1)first method<br />
pString = (char**)calloc(32*32,sizeof(char));<br />
1)Second method<br />
pString = new char[32][32];<br />
....<br /> both of them don't allocate memory properly.
Is there any other way to allocate multi-dimensional pointers?
thanks
It is never late to learn
|
|
|
|
|
in C (therefore C++), you could do this :
char matrice[10][10] = NULL;
matrice = malloc(10*10*sizeof(char));
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
matrice[i][j] = '\0';
}
}
of course, never forget to free the memory you allocated with malloc (and in C++, never forget to delete the memory you allocated with new ).
however, C++ provides built-in containers which are more secure when dealing with dynamically-sized arrays, and prevent from memory leaks...
for that, you may have a look at std::vector<> , std::list<> , std::deque<> , std::map<> ...
|
|
|
|
|
Thanks for reply,
Your method works for multi-dementional arrays, but that does not work for char **.
is there any other way to allocate type char**?
thanks
It is never late to learn
|
|
|
|
|
Gofur Halmurat wrote: 1)Second method
pString = new char[32][32];
pString = new char*[nFirstDimension];
for (int x = 0; x < nFirstDimension; x++)
pString[x] = new char[nSecondDimension];
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Thanks for your reply?
it helped to think that way in your code.
<br />
char** pString;<br />
pString = (char**)calloc(32,sizeof(char*));<br />
for(int i=0;i<32;i++)<br />
{<br />
pString[i]=(char*)calloc(32,sizeof(char));<br />
}<br />
do u think it is right what i did?
thanks
It is never late to learn
|
|
|
|
|
thanks everybody,
This method is working.
thanks
It is never late to learn
|
|
|
|
|
Hi,
I am having the below environment.
My application is running in machine A. It has an access database in the local machine and a connection will be established when the application starts and will end when the application exits. I am using CDatabase to connect to the DB.
I need to delete a record presents in the machine A database from machine B. To do this, i am creating a connection from machine B to machine A's database and executing the delete query. During the SQL execution, I am getting an error 'Could not update; currently locked by user admin...'.
The frequency of the error is often but not at all tries.
I welcome your ideas in resolving this issue.
Thanks in advance.
Selva
|
|
|
|
|
So does machine A have any part of the database open? When this error pops up, have you checked to see what process may have a file open?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hi,
Yes. From machine A will always be holding a connection with the database until the application exits.
But Access supports shared access of DB. isn't it?
Moreover i am not getting the error at all tries. Only once in 3 or 4 times.
Is there any way of avoiding the locking of the records? i.e allowing two users to update the record at the same time..
I have got something from the web, where they ask to wait for some time and do the process again. But in my case even that doesn't workout.
Please see the link below.
http://www.dbforums.com/archive/index.php/t-525401.html[^]
Thanks
Selva
|
|
|
|
|
SelvaKr wrote: But Access supports shared access of DB. isn't it?
As far as I know it does. But you first need to determine what process has the file(s) open such that machine B cannot update them. Is it your application running on machine A, or some other application?
"Normal is getting dressed in clothes that you buy for work and driving through traffic in a car that you are still paying for, in order to get to the job you need to pay for the clothes and the car and the house you leave vacant all day so you can afford to live in it." - Ellen Goodman
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
|
|
|
|
|
Hello everyone,
Here is my understanding of what Bjarne said in his The C++ Programming Language book. I am not sure whether my understanding is correct? I am somewhat confused about the following statements.
My understanding is,
means if a function call like this,
void func(const A a)
then compiler can deduce argument type of template function below to A?
template <class T> func (T a)
Bjarne's original statements are,
--------------------
C.13.4 Deducing Function Template Arguments
A compiler can deduce a type template argument, T or TT , and a nontype
template argument, I, from a template function argument with a type composed of the following constructs:
T const T volatile T
T* T& T[constant_expression]
type[I] class_template_name<T> class_template_name<I>
T T<T > T<I > T<>
--------------------
thanks in advance,
George
|
|
|
|
|
Yes, the only bit you're missing is the call to func
int i = 6;
func( i );
Now the compile can deduce that the call it to template<int> func(int a)</int> . In other words it works out the template types backwards from known matches with parameter types. Clever isn't it, just be glad you aren't implementing a C++ compiler
Nothing is exactly what it seems but everything with seems can be unpicked.
|
|
|
|
|
Thanks Matthew,
Question answered.
regards,
George
|
|
|
|
|
in a source file(.cpp and .h), how can I know it call the dll?
if it calls the dll, how can I make it call the static lib instead of dll, can anyone give me specific instruction about this topic?
|
|
|
|
|
My head asplode.
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
asplode? i think you mean to say explode
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow Never mind - my own stupidity is the source of every "problem" - Mixture
cheers,
Alok Gupta
VC Forum Q&A :- I/ IV
Support CRY- Child Relief and You
|
|
|
|
|
wendyyue wrote: in a source file(.cpp and .h), how can I know it call the dll?
if it calls the dll, how can I make it call the static lib instead of dll, can anyone give me specific instruction about this topic?
The calling of a lib or dll is determined at link time. If you link with the dll's import library, the code will call the dll. If you link with the static library, your code will call that.
Nathan
|
|
|
|
|
Hi all,
I am writing a simple file and reading tha file....
i want to do it through serialization. but don't know where to start from....
Can anybody help me in doing so.....
Thanks in advance
|
|
|
|
|
|
hello everyone
could you pls help me in solving my problem with dll.This is the first time im creating a dll.
i made the dll which has 2 function.
void disp()
{
MessageBox();
}
void retval(int i)
{
return i;
}
in my application i used loadlibrary function for inserting my dll.if i call my first function it does not provide any error but when i call the second function it is generating an error saying "the value of esp is not saved properly across the function call".
Can anybody tell me how to solve it.
Thanks in advance
|
|
|
|
|
void retval(int i)
{
return i;
}
Look at the word VOID that is your return type... I suspect that has a lot of your trouble.
Iain.
Iain Clarke appears because CPallini still cares.
|
|
|
|
|
How did he get to compile it successfully?
Nobody can give you wiser advice than yourself. - Cicero
.·´¯`·->Rajesh<-·´¯`·.
Codeproject.com: Visual C++ MVP
|
|
|
|
|
sorry that was a mistake occured while typing this is the exact code and i have commented where the error is occuring
actually the return value was a mistake occured while type.... ill send you the sample code of how i tried to create the dll..it is as follows
//MY APPLICATION FILE
//----------------------------------------------
#include <windows.h>
typedef UINT (CALLBACK* LPFNDLLFUNC1)(VOID);
typedef UINT (CALLBACK* LPFNDLLFUNC2)(LPCSTR);
HINSTANCE hDLL;
LPFNDLLFUNC1 MyFunc1;
LPFNDLLFUNC2 MyFunc2;
UINT uReturnVal;
int main() {
hDLL = LoadLibrary("C:\\sample1.dll");
if (hDLL != NULL)
{
MyFunc1 = (LPFNDLLFUNC1)GetProcAddress(hDLL,"MyDLLFunc1");
MyFunc2 = (LPFNDLLFUNC2)GetProcAddress(hDLL,"MyDLLFunc2");
if (!MyFunc1 || !MyFunc2)
{
//Show error message
FreeLibrary(hDLL);
return false;
}
else
{
uReturnVal = MyFunc1();
uReturnVal = MyFunc2("HELLO WORLD!");//GETTING AN EXCEPTION HERE…..IT IS CALLING THE FUNCTION IN THE DLL BUT AFTER THAT THE EXCEPTION OCCURS
}
}
return true;
}
//----------------------------------------------------------------
//MY DLL CREATION FILE
//-----------------------------------------------------------------------
// sample1.cpp : Defines the entry point for the DLL application.
//
#include "stdafx.h"
BOOL APIENTRY DllMain( HANDLE hModule,
DWORD ul_reason_for_call,
LPVOID lpReserved
)
{
return TRUE;
}
int MyDLLFunc1() {
MessageBox(NULL,"My DLL Function 1","",MB_OK);
return true;
}
int MyDLLFunc2(char *TEXT) {
MessageBox(NULL,TEXT,"",MB_OK);
return true;
}
//------------------------------------------------------------------------
//MY DEFINITION FILE
//------------------------------------------------------------------------
LIBRARY sample1
DESCRIPTION This is my DLL file!
EXPORTS
MyDLLFunc1 @1
MyDLLFunc2 @2
//comments
//the error is generating after this line uReturnVal = MyFunc2("HELLO WORLD!");
can you help me out
|
|
|
|