|
I dont think it is a good practice to allocate a viod pointer. Void pointer is not introduded so as to allocate and use, rather its use is in holding data. Since Void can hold any type of data. You cannot able to allocate the exact length. Thats why complier doesnot allow you to do so.
So it better to allocate for some data types.
|
|
|
|
|
c[i-1] is a void *
c[i-1] + 1 you're trying to increment to the next "void" object, but void has no size
change the line of code
void** c = malloc(20)
to
int** c = malloc(20)
and you'll see that it compiles.
|
|
|
|
|
liquid_ wrote: I'd expect that size of any pointer is known.
This is true.
Size of a pointer is 32 bits in 32-bit Windows and 64 bits in 64-bit Windows.
But the error talks about something else.
Consider this example.
int* i = 10;
This uses 4 bytes to store the value 10
char* c = 10;
This uses 1 byte to store the value 10
This is what the above error talks about.
So if you do
void* v = 10;
you should get this error since the compiler is not able to get the size needed.
«_Superman_»
I love work. It gives me something to do between weekends.
|
|
|
|
|
Hi,
I am making my application unicode supporting one.. i face the following problem..
If i copy a unicode content and paste it in the edit box by ctrl+v operation, its pasting some junk values.. whereas if i give rightclick(mouse)+paste, its copying fine...
Later, i came to know that windows clipboard doesnt support unicode characters..
I use windows xp now...
Does anyone have any idea on how to overcome this problem..
Thanks,
Rakesh
|
|
|
|
|
Rakesh5 wrote: Later, i came to know that windows clipboard doesnt support unicode characters..
You came to know WRONG. (Unless you knew that pre-1994)
From the docs: (http://msdn.microsoft.com/en-us/library/ms649013(VS.85).aspx[^])
CF_TEXT Text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data. Use this format for ANSI text.
CF_UNICODETEXT Windows NT/2000/XP: Unicode text format. Each line ends with a carriage return/linefeed (CR-LF) combination. A null character signals the end of the data.
I hope that makes things simpler for you!
Iain.
I have now moved to Sweden for love (awwww).
If you're in Scandinavia and want an MVP on the payroll (or happy with a remote worker), or need cotract work done, give me a job! http://cv.imcsoft.co.uk/[ ^]
|
|
|
|
|
Thanks a ton Iain clarke...
It worked fine...
Thanks once again..
Rakesh
|
|
|
|
|
|
Hi Experts,
I have created an Database application using CDatabase and CRecordset.
Following is some part of code where the Exception occurs....
CRecordset UserRs(&UserCn);
.
.
Sql="Select * from UserInfo";
UserRs.Open(CRecordset::snapshot,Sql,CRecordset::none);
The Exception is :
"Attempt to open a table failed-there were no columns to retrieve were specified.."
I m confused..Becoz the same code run on my machine doesnt work on
others machine.
and the query also correct.
plz Help me..
Waitng for ur Reply..
I have never failed,I just found 1000 ways that never works.
Regards,
Victory.
|
|
|
|
|
Assuming that there is a table in your DB called UserInfo, I would check that the CDatabase object is connected to the datasource using UserCn.IsOpen before trying to open the RS.
Check that the datasource is configured the same on the target machine as it is on yours - including permissions. In my experience, that is the most common source of this type of problem... though I admit my needs have never occasioned use of C++ for database connectivity.
MZR
|
|
|
|
|
Hi All,
I'm having real difficulty in getting transparency to work in my application. I am drawing an image into the window title bar, the code (in short) is below:
void CThemedDialog::OnNcPaint()
{
CDC* pWindowDC = GetWindowDC();
CRect rcWindow;
GetWindowRect(rcWindow);
m_bitmapWindowIcon.Draw(pWindowDC->GetSafeHdc(), 5, 5);
ReleaseDC(pWindowDC);
m_bitmapWindowIcon is an ATL::CImage object that is loaded from a png file (I've also tried with a jpeg file). I never get any transparency - just white pixels where the transparent ones should be. Is there something stupid I am doing? I'm pulling my hair out over this!
Thanks in advance,
Dave
|
|
|
|
|
Please clear you question
|
|
|
|
|
in a textbox i have "Sam james thomas" which is 3 names
can anyone write a code that will only take the middle name in C++
thanks
|
|
|
|
|
Um, yep. Pretty much anyone can do it.
|
|
|
|
|
You can use of CString::Mid.
Of one Essence is the human race
thus has Creation put the base
One Limb impacted is sufficient
For all Others to feel the Mace
(Saadi )
|
|
|
|
|
thats a real basic homework:
1. find the 2 blank positions
2. extract the chars in between
it is no question it is a sign thats you arent engaged enough for writing code
Press F1 for help or google it.
Greetings from Germany
|
|
|
|
|
Tiyani Miyambo wrote: "Sam james thomas"
strtok(strtok("Sam james thomas", " "), null);
|
|
|
|
|
ahmed zahmed wrote: strtok(strtok("Sam james thomas", " "), null);
Maybe you meant this as a joke. Otherwise, you can't seriously think it would produce the desired result.
"Old age is like a bank account. You withdraw later in life what you have deposited along the way." - Unknown
"Fireproof doesn't mean the fire will never come. It means when the fire comes that you will be able to withstand it." - Michael Simmons
|
|
|
|
|
you are correct, it won't produce the desired result. what was i thinking?
strtok("Sam james thomas", " ");
strtok(null, " ");
|
|
|
|
|
I have a thread going on a little way down, about threads and timing. Now a question came up that I felt should go into a different thread.
I have the following code piece
HANDLE hTimerQueue = CreateTimerQueue();
HANDLE hTimer;
count = 0;
CreateTimerQueueTimer(&hTimer, hTimerQueue, (WAITORTIMERCALLBACK)&DoSendHere, 0 , 20, 0, WT_EXECUTEINTIMERTHREAD);
QueryPerformanceCounter(&liStart);
::SleepEx(60, TRUE);
LONG lCount = count;
QueryPerformanceFrequency(&liFreq);
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Time = %f.\n", double(liEnd.QuadPart-liStart.QuadPart) / double(liFreq.QuadPart) );
m_pLogger->Out( Logger::DEBUG, "RTPEngine: Count = %d.\n", lCount );
The liEnd variable is filled in the callback function.
Several issues:
1. Like it is the callback func is called once (like intended) but the output gives a time of appx. 30ms, not 20ms. Actually the time is never the time I set up.
2. Why does it crash if I call DeleteTimerQueueTimer( hTimerQueue, hTimer, NULL ); after the output?
The output is this
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.030410.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.030192.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.030377.
RTPEngine: Count = 1.
This is the output for a 9ms dueTime:
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.016252.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.014759.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.014178.
RTPEngine: Count = 1.
RTPEngine: Sending data package with size 480 (excluding header).
RTPEngine: Timer callback activated.
RTPEngine: Time = 0.014759.
RTPEngine: Count = 1.
Souldrift
modified on Monday, July 6, 2009 5:53 AM
|
|
|
|
|
I can't reproduce your results - I always see the timer triggering roughly (within around 2-300 microseconds) when expected.
Note that in my initial post about timer queue timers I posted the wrong callback function signature - that could have caused crashes, as there was an extra formal parameter - sorry about that.
You may find it useful to investigate the different values in the Flags parameter of CreateTimerQueueTimer - the callback doesn't have to execute in the same thread as the timer.
Java, Basic, who cares - it's all a bunch of tree-hugging hippy cr*p
|
|
|
|
|
Well, I made a small adaption to your code like this (some output and another timing behaviour)
#include <windows.h>
#include <tchar.h>
#include <iostream>
LONG count;
LARGE_INTEGER liStart, liEnd, liFreq;
VOID CALLBACK DoSendHere(__in_opt LPVOID lpArgToCompletionRoutine,
__in DWORD dwTimerLowValue,
__in DWORD dwTimerHighValue)
{
QueryPerformanceCounter(&liEnd);
count++;
std::cout << "Time = " << double(liEnd.QuadPart-liStart.QuadPart) / double(liFreq.QuadPart) << std::endl;
}
void SendLoop()
{
HANDLE hTimerQueue = CreateTimerQueue();
HANDLE hTimer;
count = 0;
QueryPerformanceFrequency(&liFreq);
CreateTimerQueueTimer(&hTimer, hTimerQueue, (WAITORTIMERCALLBACK)&DoSendHere, 0 , 0, 9, WT_EXECUTEINTIMERTHREAD);
QueryPerformanceCounter(&liStart);
::SleepEx(65, TRUE);
LONG lCount = count;
DeleteTimerQueueTimer(hTimerQueue, hTimer, 0);
std::cout << "Time = " << double(liEnd.QuadPart-liStart.QuadPart) / double(liFreq.QuadPart) << std::endl;
std::cout << "count = " << lCount << std::endl;
}
int _tmain(int argc, _TCHAR* argv[])
{
SendLoop();
getchar();
return 0;
}
The result shows the same 15ms jumps I had before. Maybe there´s just no way around. I guess, I think some more and then we might have to settle for a different approach.
Thanks once again for ideas and brainstorming.
Souldrift
|
|
|
|
|
Hej Everyone,
I opened MS word file in NOTEPAD and saved it as text file so that i can read the saved file using C/C++ streams. Below i have given image of MS word file opened in NOTEPAD and then i tried to read it using C/C++ streams but my programs reads the first few characters and then terminates. Why can't i read all these characters?
http://i41.tinypic.com/nybvih.jpg[^]
Any help in this regard will be appreciated.
Thanks
|
|
|
|
|
Post some relevant code snippet otherwise we can't guess what you are doing wrong.
|
|
|
|
|
int main()
{
ifstream file("test.txt");
char ch;
if (file.is_open())
{
while ( !file.eof() )
{
file >> ch;
cout << ch;
}
}
getchar();
return (0);
}
-
This program just read the first few (5 to 6) characters of the MS word file saved as text file. How to read the remaining characters?
|
|
|
|
|
Are you aware that the file contains binary data ? What are you trying to achieve exactly ? Trying to output to the screen a binary file is probably not a good idea...
|
|
|
|