|
You're right.
There are so many crazy ways to do things.
|
|
|
|
|
Hey, I just came across a little problem and wanted to ask for your guys opinion.
What would be the most elegant solution to fix this little issue.
if (GetDriveType(drv) == DRIVE_FIXED)
{
GetDiskFreeSpaceEx(drv,0,&DiskSpace,&FreeDiskSpace);
itoa(GetTickCount()/1000%60,ds,10);
itoa(GetTickCount()/1000%60,fs,10);
string temp = "test " + ds + " dasd" + fs;
}
error C2110: '+' : cannot add two pointers
Open for any suggestions, greetings !
|
|
|
|
|
ALLERSLIT wrote: Open for any suggestions, greetings !
You did not show how ds and fs were declared, but one way might be:
string temp = string("test ") + ds + string(" dasd") + fs;
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Does not work out for me.
Getting theese errors:
Does not work out for me.
\test\main.cpp(18) : error C2784: 'std::_String_iterator<_Elem,_Traits,_Alloc> std::operator +(_String_iterator<_Elem,_Traits,_Alloc>::difference_type,std::_String_iterator<_Elem,_Traits,_Alloc>)' : could not deduce template argument for 'std::_String_iterator<_Elem,_Traits,_Alloc>' from 'char [5]'
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(440) : see declaration of 'std::operator +'
\test\main.cpp(18) : error C2784: 'std::_String_const_iterator<_Elem,_Traits,_Alloc> std::operator +(_String_const_iterator<_Elem,_Traits,_Alloc>::difference_type,std::_String_const_iterator<_Elem,_Traits,_Alloc>)' : could not deduce template argument for 'std::_String_const_iterator<_Elem,_Traits,_Alloc>' from 'char [5]'
1> c:\program files\microsoft visual studio 9.0\vc\include\xstring(300) : see declaration of 'std::operator +'
\test\main.cpp(18) : error C2784: 'std::reverse_iterator<_RanIt> std::operator +(_Diff,const std::reverse_iterator<_RanIt> &)' : could not deduce template argument for 'const std::reverse_iterator<_RanIt> &' from 'char [5]'
1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(2203) : see declaration of 'std::operator +'
\test\main.cpp(18) : error C2784: 'std::_Revranit<_RanIt,_Base> std::operator +(_Diff,const std::_Revranit<_RanIt,_Base> &)' : could not deduce template argument for 'const std::_Revranit<_RanIt,_Base> &' from 'char [5]'
1> c:\program files\microsoft visual studio 9.0\vc\include\xutility(2003) : see declaration of 'std::operator +'
\test\main.cpp(18) : error C2676: binary '+' : 'std::basic_string<_Elem,_Traits,_Ax>' does not define this operator or a conversion to a type acceptable to the predefined operator
|
|
|
|
|
string temp = string("test ") + string(ds) + string(" dasd") + string(fs);
|
|
|
|
|
ostringstream os;
os << "test " << ds << " dasd" << fs;
string temp = os.str()
|
|
|
|
|
Hi,
This would do the same without ugly and dangerous multiple additions of std::string and const char* :
#include <sstream>
if (GetDriveType(drv) == DRIVE_FIXED)
{
GetDiskFreeSpaceEx(drv,0,&DiskSpace,&FreeDiskSpace);
std::ostringstream oss;
oss << "test " << GetTickCount() / 1000 % 60;
oss << " dasd " << GetTickCount() / 1000 % 60 << std::ends;
std::string temp = oss.str();
}
cheers,
AR
When the wise (person) points at the moon the fool looks at the finger (Chinese proverb)
modified on Saturday, October 30, 2010 2:51 AM
|
|
|
|
|
I need to implement a class that offers a client two ways to output data, depending on if they want to display it in ASCII or store it in binary. I figured the best way to implement the ASCII output would be to use a friend function as follows:
friend ostream& operator <<(ostream&, myClass const&); However, to offer a binary output option, I don't know whether I should create a friend function or a class method, and was wondering if there is an accepted best practice in such a scenario. The two options I am considering are:
friend ostream& write(myClass const&);
void write(ostream&) const; If either of these methods (or some other method) is the preferred way of offering such functionality, I would be interested to hear about it.
Similarly, I need to implement the binary input method, for which I have the following three conceivable options:
friend istream& read(myClass&);
void read(ostream&);
static void read(myClass *&, ostream&); Thanks for the help,
Sounds like somebody's got a case of the Mondays
-Jeff
|
|
|
|
|
hi all
in neural networks algo of face detection a term is used a lot " training neural network". what does it mean? and a file is used with extension of NNCP which is loaded first. as for as i know that file contains different patterns of faces. i wana implement the neural network algorithm but i don't understand how to train neural network and how to make this NNCp file which contains different face paterens.
any suggestions links will be appreciated.
thanks
|
|
|
|
|
I don't know how many times you plan to ask this question again, but your time would be better spent taking some of the advice that has already been offered. This article[^] has already been suggested as a starting point; try and spend some time learning from it.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
Hi
I already post same question yesterday. I still did not get decent solution for it. I found real cause now. So I post it again here.
The real problem cause:
If I run "VS 2008 debug" and exit my app. Then next time when I tried to build the EXE file, I will get this error. If I don't run debug and just compile the code and link, I will not have this problem.
So I am thinking, VS itself is using it and did not release when I stop debug.
Any ideas?
Best regards,
|
|
|
|
|
transoft wrote: Any ideas?
Does your app have more than one thread?
"One man's wage rise is another man's price increase." - Harold Wilson
"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
"Man who follows car will be exhausted." - Confucius
|
|
|
|
|
Before I used it under Windows XP, I never had this problem. Since I moved to Window 7, this type problem keep coming out.
I did not use multi-thread.
Thank you for your reply.
modified on Saturday, October 30, 2010 12:39 AM
|
|
|
|
|
I hope to use a Socket to a Web server to send request, and then obtain Web server respond to my data. But in the response data inside, there is always a response head, how should I get rid of the response head. I tried by the response data length to intercept head off response head data, but I failed, because of different response, data different lengths. How should I do?
#include <stdio.h>
#include <winsock2.h>
#pragma comment(lib,"WS2_32")
void PacketSocket(const char *host,const char *url,const char *data,char *reBuf)
{
wsprintf(reBuf,"POST %s HTTP/1.1\r\nAccept:text/html\r\nAccept-Language:zh-cn,en\r\nAccept-Encoding:gzip,deflate\r\nContent-type:application/x-www-form-urlencoded\r\nAccept-Charset:GBK\r\nHost:%s\r\nContent-Length:%d\r\nContent-Encoding:utf-8\r\nUser-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.3))\r\nConnection:Keep-Alive\r\nSet-Cookie:JSESSIONID=193F85DD5F193A5714CBC5246218ECO3\r\n\r\n%s",url,host,strlen(data),data);
}
int main(){
WSADATA wsa;
WORD version=MAKEWORD(1,1);
if(WSAStartup(version,&wsa)==SOCKET_ERROR){
printf("start error!");
return -1;
}
SOCKET s;
sockaddr_in addr;
s=socket(AF_INET,SOCK_STREAM,IPPROTO_TCP);
if(s==INVALID_SOCKET)
{
printf("has a error,the code:%d",GetLastError());
return -1;
}
addr.sin_addr.S_un.S_addr=inet_addr("127.0.0.1");
addr.sin_port=htons(8080);
addr.sin_family=AF_INET;
if(connect(s,(sockaddr*)&addr,sizeof(addr))==SOCKET_ERROR){
printf("connect had an error!");
return -1;
}
char szData[1024];
PacketSocket("localhost","/socket/index.jsp","start=0&limit=15",szData);
if(send(s,szData,strlen(szData),0)==SOCKET_ERROR){
printf("send request had an error!");
return -1;
}
char szRecv[1024];
int nCount=recv(s,szRecv,1024,0);
if(nCount>0)
{
szRecv[nCount]='\0';
printf("%s",szRecv);
}
WSACleanup();
return 0;
}
Response data as follows
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=0910F038DEBB2C62C41C53A4E30C1C00; Path=/socket
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 582
Date: Fri, 29 Oct 2010 14:45:46 GMT
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Hello,Win32 socket!</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
Receiving request, then this page response to the client
</body>
</html>
Press any key to continue
How do I get from response data removing the following data
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=0910F038DEBB2C62C41C53A4E30C1C00; Path=/socket
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 582
Date: Fri, 29 Oct 2010 14:45:46 GMT
thank you very much!
|
|
|
|
|
Skip over the double newline (as defined in RFC 1945, RFC 2616) -or- use a networking library with a HTTP client.
|
|
|
|
|
How to get the Top-level menu ID and change it on the run time. I am able laod trhe name of child menu item using Menu ID. But I don't knoe how to load the name of top lavel menu (like File, View, Help) at run time.
Please any one can help me.
Thanks...
|
|
|
|
|
I think GetMenu()[^] is the function you are looking for.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
You are right, but my query is how I will get the parent menu (FILE, View,Help) using get menu. I am able to get the child menu and modifying it using ModifyMenu(); Here is my code:-
CMenu *pMenu = GetMenu();
pMenu->ModifyMenuW(ID_FILE_PRINT_REPORT,0,ID_FILE_PRINT_REPORT,"Open File");
Here "Open File" is inside file menu.
Now I want to change the name of "File" to "File report", for that I need to know the ID of file which is parent menu.
|
|
|
|
|
I think you are probably referring to GetSubMenu()[^]. Take a look at the class hierarchy in MSDN to see what other methods each class offers.
Just say 'NO' to evaluated arguments for diadic functions! Ash
|
|
|
|
|
I think you might need to use "GetMenu()" in the CMainFrame" class.
|
|
|
|
|
Hi all ,
I view the code in file barstat.CPP in MFC's code . I see method CalcFixedLayout of it . If CalcFixedLayout haven't , status bar will invisible .
I search on MSDN and I see framework don't call to this method .
I don't see this barstat.CPP call to it .
I don't understand why I don't call it but if it haven't , status bar will invisible . Perhaps , the framework call it .
Thanks for helping .
|
|
|
|
|
Hi all,
I have two worker thread.
one thread is populating the list and second thread is doing operation on that list.
my problem is i want that after i have populated the list then only second thread should start.
How can i do it?
Thanks in advance
|
|
|
|
|
In the second thread you can use WaitForSingleObject() to wait for the first thread's handle to complete.
|
|
|
|
|
1. Start 1st thread.
2. Wait for it to finish.
3. Start 2nd thread.
learningvisualc wrote: my problem is
??
Starting to think people post kid pics in their profiles because that was the last time they were cute - Jeremy.
|
|
|
|
|
In addition to the previous answer: is there a particular reason why you want to use a second thread ? You have to wait until the first thread is finished, so why don't you simply execute that task in the same thread as the first one. I don't really see an added value of starting a second thread when the first one terminates.
|
|
|
|
|