Hello guys,
I thought I understood all of C but the complex stuff sometimes gets me.
Can you learn me.
I'm trying to figure out how to put a variable inside a variable.... Here is the code excerpt.
CODE IS char * httpget = "GET /mssql.php?q=11101000101001101111111000000011 HTTP 1.1 / \x0D\x0A\n\x0D\x0A\n" ;
Any idea on how I would get the binary portion to be a variable that pulls from elsewhere?
Thanks, for everyone's help.
sprintf()?
With the lack of binary number support in sprintf() I would use a loop that shifts and tests bits in an integer and adds '0' or '1' to a string. And then strcpy(), strcat() or similar to add the tail part.
sprintf() can be made to do all manner of things, including printing numbers in all kinds of bases.
#include <stdio.h> #include <stdlib.h> char httpget[128]; char buffer[33]; sprintf(httpget, "GET /mssql.php?q=%s HTTP/1.1\r\n", atoi(i, buffer, 2));
Should have been itoa(), damn the lack of an edit
sprintf(httpget, "GET /mssql.php?q=%s HTTP/1.1\r\n", itoa(i, buffer, 2));