|
Stephen Hewitt wrote: This is not always the case: the pointer need not be allocated on the stack.
Agreed. I just didn't want to confuse the OP more by attempting to explain where pointers themselves are allocated
Regards
Senthil
_____________________________
My Blog | My Articles | My Flickr | WinMacro
|
|
|
|
|
hi,
pointer holds the address of a variable.
u r saying that integer 2 is stored in 1000 and 1001 as 0000 0010.
Now p points to 1000, which is the base address of integer 2.
In the case of p=&j
j=4;
pointer will be adjusted to the address of j. Hence *p and j will prints the same value.
|
|
|
|
|
int * p ;
//"say the locations are 1000 and 1001."-it's ok..
//that means The locations 1000 and 1001 are rady to hold address
//of an integer. If write
*p=2; //means you are trying to assign integer value on the address
//which is store on 1000 and 1001.
//So it will cause acess violation.at run time.
// we can do this after assign p=&j;
p=&j;
//Then
*p=2;
//means the Now 1000 and 1001 is holding the address of "j";
//And the value of that Address will be 2;
//Now *p and j will print the same value.
Saday Chand Sarkar
Software Engineer
Trek Technology(s)Pte.Ltd.
|
|
|
|
|
Thank you.I have doubt only in the memory part..I think I understand how values are being manupulated through pointers
can we do like this...
int *p,x // allocating 4 bytes for pinter p in memory;
float k //allocating 4 bytes.
p=&k // this will work very well.
Now,
k=&p // what will happen now
or k=&x;// if k has enough space to store the address of it can hold.
But then
*k should work ,I know,which will not
Thanks
-- modified at 3:15 Friday 26th May, 2006
|
|
|
|
|
An int* pointer can not (without perverse casting) point to a float. Simple pointers like the ones you're using will always be a fixed size; on 32-bit Windows this will be 4 bytes. The actual value of a pointer (the bit pattern in memory) indicates a location in memory where some data starts; the type of the pointer tells the compiler what type of data to expect. The example you gave will not compile - BUT if it did this is what it would be saying:
Make the pointer "p" point the data for the variable "k". When the user indirects through the pointer "p" treat the data as if it was an integer.
Steve
|
|
|
|
|
Thank you stephen,
Your reply forcing me to study stack and heap concepts of memory more deeply, though I know it theoratically.It would be nice,If you can point me to some good stuffs and articles.
Thank you...
|
|
|
|
|
hi,
I was facing a problem while i was developing a code, which should run on different OS like linux and windows. The only function in linux for which i could not find a windows equivalent was gettimeofday() which returns the system time. My only requirement in windows code is that I donot want any dependency on windows libraries. So, though there exists many functions in windows libraries to retrieve the system time, they all require either windows.h or some other specific windows based headers which i dont want.
So can anybody suggest an alternate to gettimeofday() which does NOT have any dependency on windows whatsoever but is a plain c/c++ implementation.
Thanks in advance for any help.
|
|
|
|
|
use SYSTEMTIME structure or CTime
Cheers
"Peace of mind through Technology"
|
|
|
|
|
Ganesh_T wrote: use SYSTEMTIME structure or CTime
these function are not available in LINUX, i believe User want to make Multiplateform Application!
"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
Help CRY
|
|
|
|
|
#include <time.h>
#include <stdio.h>
void main( void )
{
char dbuffer [9];
char tbuffer [9];
_strdate( dbuffer );
printf( "The current date is %s \n", dbuffer );
_strtime( tbuffer );
printf( "The current time is %s \n", tbuffer );
} Does this help you? I got this from MSDN while searching for _strtime .
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
What's the point in using gettimeofday() under linux, which is a linux specific function, if you don't want to use the equivalent under Windows? The equivalent is the GetSystemTime() function, but since it is Windows specific, you probably don't want it. The only other way would be to use the standard C library time() function, but then why don't you just use that under linux as well?
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"
|
|
|
|
|
I am working in network programming. Its a multiclient server chat program. Each client works in saparate thread. I create thread when some client request the server to connect. I used _beginthread to create thread.
When i build the file, i get following error.
unresolved external symbol __beginthread
I have included ws2_32.lib but still it does not work.
Can you please help me?
Thanks
We Believe in Excellence
www.aqueelmirza.cjb.net
|
|
|
|
|
Aqueel wrote: I am working in network programming. Its a multiclient server chat program. Each client works in saparate thread. I create thread when some client request the server to connect. I used _beginthread to create thread.
When i build the file, i get following error.
unresolved external symbol __beginthread
I have included ws2_32.lib but still it does not work.
Can you please help me?
Thanks
You have to link to MSVCRT.lib or LIBCMT.lib library.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
#if !defined(_MT)
#error _beginthread requires a multithreaded C run-time library.
#endif
Need to include the lines above in your file where you have used _beginthread and #include<process.h>
That should do the trick....
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Aqueel wrote: used _beginthread to create thread.
When i build the file, i get following error.
unresolved external symbol __beginthread
Its better if you use CreateThread Instead!
"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
Help CRY
|
|
|
|
|
How i can clear the List box ?
How i can count the lines of a list box ?
List box
test.txt
tess.txt
test.mp3
test.doc
test.dll
now How i can say " in 3rd line is test.mp3"
|
|
|
|
|
Immunity18 wrote: How i can count the lines of a list box ?
GetCount();
Immunity18 wrote: How i can clear the List box ?
ResetContents();
Immunity18 wrote:
test.txt
tess.txt
test.mp3
test.doc
test.dll
now How i can say " in 3rd line is test.mp3"
From MSDN:
CString str, str2;
int n;
for (int i=0;i < pmyListBox-><code>GetCount()</code>;i++)
{
n = pmyListBox->GetTextLen( i );
pmyListBox-><code>GetText</code>( i, str.GetBuffer(n) );
str.ReleaseBuffer();
str2.Format(_T("item %d: %s\r\n"), i, str.GetBuffer(0));
MessageBox(str2);
}
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
thx you for the replies \o/
Hm the thing i want to do is.
When i'll doubleclick on an item then save me in a variable the number of the line
test.txt
tess.txt
test.mp3
test.doc
test.dll
if someone double click on test.mp3 it gonna say "you select 3 line"
|
|
|
|
|
Immunity18 wrote: When i'll doubleclick on an item then save me in a variable the number of the line
Inside the message handler for double click...
int nIndex = pmyListBox->GetCurSel(); nIndex now contains the index of the currently selected item.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
I got an MFC application where i have a Playlist.
the MFC application plays the mp3 via Winamp.
When i add a mp3 on the Playlist ,at the same time it is added on the Winamp Playlist.
There is a command on Winamp (takes int 1,2,....) which is the position on playlist
So when I doubleclick on an item on 5rd line it gonna give the int value 5 at a variable.
The same variable will be in the command on Winamp for position on Playlist
|
|
|
|
|
Immunity18 wrote: So when I doubleclick on an item on 5rd line it gonna give the int value 5 at a variable.
The same variable will be in the command on Winamp for position on Playlist
That's great.
Nibu thomas
A Developer
Programming tips[^] My site[^]
|
|
|
|
|
Yeah \o/ its great for a newbie like me (now i start learn C++)
I thought about adding a int counter++
m_ListCtrl("%d "+Filename ,counter);
so it would be
1 filename.txt
2 filename.mp3
3 dsffsfds...
And after with GetAt();, for the first character of each item , i could "read" the number of line
Just i wanted to ask if there was a way to avoid that .
|
|
|
|
|
1)Match the contents of the list box by iterating through the items. If you get what you want format the string . Add the name you want to and display the formatted string.
2)Use the listbox.GetCount() Method to get the number of items in the list box
3)For Clearing the list box use listbox.ResetContents()
Somethings seem HARD to do, until we know how to do them.
_AnShUmAn_
|
|
|
|
|
Immunity18 wrote: How i can clear the List box ?
Use CListBox::ResetContent Immunity18 wrote: How i can count the lines of a list box ?
Use
CListBox::GetCount<br />
<br /> Immunity18 wrote: test.txt
tess.txt
test.mp3
test.doc
test.dll
now How i can say " in 3rd line is test.mp3"
<br />
CString strList; <br />
for(int iCount=0;iCount<mylist.GetCount();iCount++)<br />
{<br />
<br />
myList.GetText(iCount,strList);<span style="font-weight: bold;"><br />
if(strList.CompareNoCase("</span>test.mp3<span style="font-weight: bold;">")==0)<br />
{<br />
strList(" The test.mp3 is at %d",iCount);<br />
MessageBox(strList);<br />
} <br />
</span> <br />
<br />
<br />
}
"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
Help CRY
|
|
|
|
|
Hi,
It takes 1 minute and 850 ms for my FTP client(only upload) app(VC6) to
upload 300 local files(size: 10kb) to a FTP server in our LAN.The FTP server
is a Micosoft FTP Server of IIS.
Now we need to improve the app performance to reduce the 1 minute and 850 ms
to 1 minute or less. My app uses WININET api and WININET.DLL.
I tried to call InternetSetOption() with INTERNET_OPTION_WRITE_BUFFER_SIZE
flag to set the write buffer size to 8092.
I want to know what the default write buffer size is and whether the app
performance is better while the size is more.
Thank you in advance.
Dave
|
|
|
|