double a;
sscanf_s("0.02", "%lf", &a);
ALLERSLIT
Posts
-
890927 - Invalid Input Format exception in sscanf_s -
'Fake' the freespace of a hddHey, basically what I am trying is to modify the data of a harddrive. I want it to show more free space than it has, i know it would be only visually but that's exactly what I am trying to do. OS would be windows server 2008, if that matters. How would I go about doing this? I tried to google but couldn't really find anything neccessary. Thanks
-
not recv()'ing everything [modified]Thanks, I got where you are coming from. Unfortunately the connection doesnt close, it just sits there. Tried sending
char strRequest[] = "GET /whois/whois.cgi?domain=127.0.0.1 HTTP/1.0\r\nConnection: Close\r\n\r\n";
but nothing. Can you suggest me an already existing library that isn't as huge as curlpp or boost, or generally one that is somewhat easy to handle? I am still new to c++ as you may know.
modified on Friday, November 26, 2010 12:13 PM
-
not recv()'ing everything [modified]Hey guys, I am trying to fetch the data from here -> http://74.54.176.106/whois/whois.cgi?domain=127.0.0.1[^] Though I am not receiving everything, this is all I get:
Tried to google but couldn't find anything that helped me.
my code:
char buffer[4096];
char strRequest[] = "GET /whois/whois.cgi?domain=127.0.0.1 / HTTP/1.0\r\n\r\n";
send(sock, strRequest, sizeof(strRequest), 0);
int i = recv(sock, buffer, sizeof(buffer), 0);modified on Friday, November 26, 2010 11:49 AM
-
timeout problemHey, this is my code:
connect(s, (SOCKADDR\*) &addrin, sizeof(addrin)); send(s, stRequest.c\_str(), stRequest.length(), 0); cout << "stRequest sent." << endl; recv(s, buffer, sizeof(buffer), 0); cout << "buffer received." << endl;
Now this works perfectly fine if the webserver is working well, but sometimes it just sits there trying to recv() forever.. Iam not exactly sure what causes it but either way, I need a way to set a timeout or something similiar.. I couldn't really find something helpfull on google, so yea I thought maybe you guys could help me out.
-
Get Port Banner?Banner is like a name that identifies the service that runs on the port. Iam just look for a way to identify what service/program runs on a port. Example: For an ftp it's the first reply: 220-FileZilla Server version 0.9.34 beta Iam looking for something similiar that works for webservers.
-
Get Port Banner?Yea, I just found that out too, so I digged some more and found out about some webscanner or whatever they are called. How do those tools get literally every(for webservers atleast) banner though?
-
Get Port Banner?Hey, I need to earn some points in my IT class and thought about writing a tool that would tell you what runs on a specific port, in this case port 80. Now it would most likely be a webserver, finding that out is no problem by checking for specific strings such as "" etc.. My problem is though, I would like to know what kinda Webserver runs on that port. How would I do that? Unfortunately the replies are not really formated, so its really hard to filter it out. Example:
is what I recv() when i send() to 109.70.146.167 on port 80.
That does not actually help me though, as the banner is not always the last message..
Sometimes the banner is not even in it at all..65.39.148.34 on port 80
I did some google digging and found out about certain tools that
-
buffer filled with trash [modified]Hey I googled for this kinda stuff but only useless stuff came up.. Anyway
char buffer\[250\]; send(sock, "hello?\\n", 8, 0); recv(sock, buffer, sizeof(buffer), 0); cout << buffer << endl; cin.get();
is my code. Now I obviously do not know how big the buffer will be, the problem is if i set buffer[250], everything after the actual content is trash. How would I fix that? Like I wanna see only the actual content and not the jibberish after it. Thanks. e// nevermind, I just found out that recv returns the size..
modified on Tuesday, November 16, 2010 7:57 PM
-
+ cannot add two pointers, most elegant solution ?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 -
+ cannot add two pointers, most elegant solution ?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 !
-
sizeof string array in for loop?I actually am using VC++, thanks for your answer!
-
sizeof string array in for loop?Thanks!
-
sizeof string array in for loop?Hey, sorry if the threadtitle is a bit in-informative but I didn't know what to call it. Ok now to my problem, I am playing around with arrays and stuff see here ->
#include <iostream>
#include <string>using namespace std;
int main()
{
string a[] = { "one", "two", "three" };for (int i = 0;i <3;i++) { cout << a\[i\] << endl; } cin.get();
}
Now my problem is the "i < 3" let's say I wouldn't want to change that everytime i add another string to my array. How would I do that? Greetings!
-
char *> string conversion , env[]Trying to figure out how to get the outpuf of env[i] without putting all that other stuff into main()'s signature.
-
char *> string conversion , env[]If I declare it the way you did, I can not put it into a string the same way i learned in the last post.
-
char *> string conversion , env[]Oh thanks, gotcha! let's say I wouldn't put
char *env[]
there into the main() thingy, how would I be able to get the output of env[i] then? Like
#include <stdio.h>
#include <iostream>
#include <string>using namespace std;
int main()
{
char *env[];
string str = env[9];
cout << str << endl;
return 0;
}I get this error: |14|error: storage size of ‘env’ isn't known Makes sense to me, but how would I avoid that error?
-
char *> string conversion , env[]Hey, Iam reading this book and Iam writing my own program aside. Iam currently reading about some functions related to linux.
#include <stdio.h>
#include <iostream>using namespace std;
int main(int argc,char *env[])
{
int i=0;
cout << env[i] << endl;
return 0;
}This is the program, now how would I actually put the output of env[i] into a string? In my own program Iam playing around with conversions and string editing and stuff, now I need to convert the output of env[i] into a string though, not sure how to do that. Thankfull for any help, greetins :)
-
Allocating memoryThanks for all answers and thanks to Richard, that will sure do the job for me!
-
Allocating memoryHey, this is my code:
char szBuffer\[1024\]; recv(sock,szBuffer,sizeof(szBuffer),NULL); printf("%s", szBuffer);
now the size of the websites vary, how would i allocate just enough memory for the actual content so the rest of the buffer wont be filled with junk ? Thanks.