|
Try this
int b;
int afunction()
{
int *ptr= &b;
int b = 0;
.....
}
|
|
|
|
|
could anyone plz tell me as soon as possible how to convert an unsigned char to const char using vc++ code?
|
|
|
|
|
nehathoma wrote:
could anyone plz tell me as soon as possible how to convert an unsigned char to const char using vc++ code?
I believe we can do it that by using normal C++ code.
I think you are looking for conversion of unsigned char string to signed char string instead of unsigned char to signed char.
Here anyways, this Task can be accomplish by using typecasting! (if you don't know what exactly the type casting is? please refer to your TEXT book!)
unsigned char *unChar=(unsigned char*) "unsigned string";
char sigString[100];
strcpy(sigString,(const char*)unChar);
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
I believe we can do it that by using normal C++ code.
I think you are looking for conversion of unsigned char string to signed char string instead of unsigned char to signed char.
Here anyways, this Task can be accomplish by using typecasting! (if you don't know what exactly the type casting is? please refer to your TEXT book!)
//typecasting By direct initialization
unsigned char *unChar=(unsigned char*) "unsigned string";
//second Unsigned char string to signed char string
char sigString[100];
strcpy(sigString,(const char*)unChar);
Which C++ book did you see the type casting as above ?
suhredayan There is no spoon.
|
|
|
|
|
I asked her to get concept of Typecasting by reading the Book.
Anyways some books taught you typecasting by using macro like static_cast , reinterpret_cast and dyanamic_cast
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
ThatsAlok wrote:
Anyways some books taught you typecasting by using macro like static_cast, reinterpret_cast and dyanamic_cast
Dear Alok,
static_cast, reinterpret_cast etc are not macros. They are casting operators in C++ language.
suhredayan There is no spoon.
|
|
|
|
|
suhredayan® wrote:
static_cast, reinterpret_cast etc are not macros. They are casting operators in C++ language.
then i am really sorry!, I take back my words !, Now i have to refer TEXT BOOK
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
but thats not working for me Alok!!!!!!!!!1
|
|
|
|
|
Hi Neha,
Could you please post some code snippet excatly where u facing problem!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
CString tr=m_edit1.Left (m);
tr.Delete (0,m-1);
tr.Format("%d",ch);(this is where i am stuck)
c i want to convert the string "tr" to char.is there any problem with the format string i have used.....
the data type used for 'ch' is unsigned char......
data =(double)ch;
|
|
|
|
|
nehathoma wrote:
CString tr=m_edit1.Left (m);
i smell some problem here!
//i don't understand use delete and format here!
tr.Delete (0,m-1);
tr.Format("%d",ch);(this is where i am stuck)
First you delete whole string except last character from tr then you copy a new string from CString::Format
please clarify what exactly you want to do here!
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|
|
u know why i used the stmt:
CString tr=m_edit1.left(m)
to retrieve th charachters in the string one by one....
tr.delete("%d",ch)
is used to convert the retrieved characters one by one to ch.....
|
|
|
|
|
nehathoma wrote:
c i want to convert the string "tr" to char.is there any problem with the format string i have used.....
CString::Format() function is used to write something into CSting object. From your post I feel you want to convert tr to character. With the assumption tr will have only one character at that time.
try this then:
ch = tr.GetAt(0);
suhredayan There is no spoon.
|
|
|
|
|
thank u i got that with what u said
|
|
|
|
|
nehathoma wrote:
thank u i got that with what u said
was a wild guess
suhredayan There is no spoon.
|
|
|
|
|
Hi All,
I am using following code to establish a secure connection. But WinHttpSenRequest() fails. The error number returned by GetLastError() is 87, which dont seems to have relation with WinHttpSendRequest().
hSession = WinHttpOpen( L"OFX Download", WINHTTP_ACCESS_TYPE_NAMED_PROXY,
L"192.168.0.48:1749", L"<local>", 0);
if (!hSession)
{
ATLTRACE("Internet Open Failed");
return false;
}
hConnect = WinHttpConnect( hSession,L"ofxServer.com" , INTERNET_DEFAULT_HTTPS_PORT , 0);
if ( !hConnect )
{
DWORD nErr = GetLastError();
WinHttpCloseHandle(hSession);
return false;
}
hRequest = WinHttpOpenRequest( hConnect, L"GET", L"/ofxproxy/ofx_proxy.dll", NULL, WINHTTP_NO_REFERER, NULL, WINHTTP_FLAG_SECURE);
if ( !hRequest )
{
WinHttpCloseHandle(hConnect);
WinHttpCloseHandle(hSession);
return false;
}
CA2W qry(csPostString.GetBuffer()) ;
bResults = WinHttpSendRequest( hRequest, qry, wcslen(qry), WINHTTP_NO_REQUEST_DATA ,0, 0 , 0);
if (!bResults)
{
DWORD dwError = GetLastError();
WinHttpCloseHandle(hRequest);
(hConnect) WinHttpCloseHandle(hConnect);
(hSession) WinHttpCloseHandle(hSession);
return false;
}
Same task is being done very efficiently using WinInet. But due to some reasons I have to move towards WinHTTP.
|
|
|
|
|
Can anyone clarify the following problem.
I have added a listcontrol to a property page and set it to 'Report' view .
I have set 'Nocolumnheader' to TRUE.
When I set the view to 'List', the list items are added and displayed but when i set it to 'Report' view no items are added to the listcontrol.
Thanx in advance
laiju
|
|
|
|
|
|
You still need to add one or more columns to the control; setting the LVS_NOCOLUMNHEADER style just hides the header control above the columns.
--Mike--
Visual C++ MVP
LINKS~! Ericahist | 1ClickPicGrabber | CP SearchBar v2.0.2 | C++ Forum FAQ
Strange things are afoot at the U+004B U+20DD
|
|
|
|
|
i appreciate ur resonse.
But i dont any columns rather i want all the items to be listed in report view.Thats the reason why i set NoColumnheader property to TRUE.
Still the items are added in list view but not in report view
laiju
|
|
|
|
|
i dont need a column header since i dont want multiple columns.
I just want to display all the list items in a report style.
Thats the reason i set NoColumnHeader to TRUE.
But even after setting NoColumnHeader to FALSE ,the list items arent visible.I guess they are not added because when i try to fetch the total count it says zero.
But my code works fine if the view property is set to ' list ' .
I have attached my code .Pls..verify if possible.
void CFontPage::OnFontSelection() // fills the list box with unique font types
{
bool bNewEntry;
int iIndex;
int iListItems;
int iResult;
TCHAR cFont[MAX_LIST_CHARS];
TCHAR cListFont[MAX_LIST_CHARS];
CString sFont;
LVITEM lvItem;
bNewEntry = TRUE;
iIndex = m_FontType.GetCurSel();
m_FontType.GetLBText(iIndex,cFont);
iListItems = m_FontList.GetItemCount();
for (iIndex = 0; iIndex < iListItems; iIndex++)
{
m_FontList.GetItemText(iIndex,NULL,cListFont,sizeof(cListFont));
iResult = strcmp(cListFont,cFont);
if (0 == iResult) //matching font .Font already available in list
{
bNewEntry = FALSE;
}
memset(cListFont,'\0',sizeof(cListFont));
}
if (TRUE == bNewEntry)
{
iListItems++;
lvItem.mask = LVIF_TEXT|LVIF_STATE;
lvItem.state = LVIS_SELECTED;
lvItem.stateMask = NULL ;
lvItem.iItem = iListItems;
lvItem.pszText = cFont;
lvItem.iSubItem = NULL;
m_FontList.SetItem(&lvItem);
m_FontList.InsertItem(&lvItem);
}
SetModified(TRUE);
}
void CFontPage::OnClickedRemove() // deletes currently selected list items
{
int iIndex;
LVITEM lvItem;
iIndex = m_FontList.GetSelectionMark(); // retrieves current selected list item
m_FontList.DeleteItem(iIndex);
}
laiju
|
|
|
|
|
laiju wrote:
iListItems++;
Why is this variable being incremented? The for loop compares iIndex to this variable to know when to terminate. By incrementing it, doesn't that mess things up?
In any case, if you are only adding data to the first column, why use a list control over a listbox?
Even though the list control has the LVS_NOCOLUMNHEADER style, you still need to make a call to m_FontList.InsertColumn(0, "", LVCFMT_LEFT, 100) so that the column width is set.
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
|
|
|
|
|
hello friends
i m making sniffer using vc++ and want some fields they r
1. system's cpu usage
2.network packet/sec.
3.memory usage
4. number of connections
5.connection attempts.
6.protocol used
7.available network bandwidth.
plz tell me functions used to retrieve these fields
plz reply soon, its very urgent.
bye
|
|
|
|
|
smarty12 wrote:
plz reply soon, its very urgent.
It's always urgent.
Christian
I have several lifelong friends that are New Yorkers but I have always gravitated toward the weirdo's. - Richard Stringer
|
|
|
|
|
smarty12 wrote:
hello friends
i m making sniffer using vc++ and want some fields they r
1. system's cpu usage
2.network packet/sec.
3.memory usage
4. number of connections
5.connection attempts.
6.protocol used
7.available network bandwidth.
look for IPhelper api's for network related problem here is URL for that
http://www.codeproject.com/internet/IPHelper.asp[^]
and for cpu related problem again here is URL
http://www.codeproject.com/threads/getprocesstimes.asp[^]
"Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow
cheers,
Alok Gupta
|
|
|
|