![]() |
|
[C] Concat an array of chars into another array or chars - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [C] Concat an array of chars into another array or chars (/showthread.php?tid=6079623) |
Concat an array of chars into another array or chars - gurlhackerclub - May 19, 2020 Want to concat a string of the active logical drives into another string, So that it can be sent over a socket. The line strcat_s is giving me issues. commented out line. Code #include <stdio.h>RE: Concat an array of chars into another array or chars - saltycracker - May 19, 2020 Well what issues? Post exactly what the problem is. RE: Concat an array of chars into another array or chars - gurlhackerclub - May 19, 2020 (May 19, 2020 05:43 AM)saltycracker Wrote: Well what issues? Post exactly what the problem is. nvm, I got it, thx Code #include <stdio.h>RE: Concat an array of chars into another array or chars - saltycracker - May 19, 2020 (May 19, 2020 07:02 AM)gurlhackerclub Wrote: nvm, I got it, thx Why are you creating a std::string from character array and then turning it back to a c string? Why not use the character array and skip the whole std::string to c string? RE: Concat an array of chars into another array or chars - gurlhackerclub - May 19, 2020 (May 19, 2020 10:40 AM)saltycracker Wrote: Why are you creating a std::string from character array and then turning it back to a c string? Why not use the character array and skip the whole std::string to c string? On this line, strcat_s(lpdrives, sizeof lpdrives, lpBuffer[i]); I was getting this error. errno_t strcat_s(char *,rsize_t,const char *)': cannot convert argument 3 from 'char' to 'const char *' I needed to send this char array through a socket. iResult = send(ConnectSocket, lpdrives, (int)strlen(lpdrives), 0); Ugly, but I got it working. Simple command line RAT. Now the only commands I can send are quit and list active drives. RE: Concat an array of chars into another array or chars - saltycracker - May 19, 2020 (May 19, 2020 11:11 AM)gurlhackerclub Wrote: On this line, Why won't you just pass the array? The array name is the pointer address. You have this: Code strcat_s(lpdrives, sizeof lpdrives, lpBuffer[i]);But did you try: Code strcat_s(lpdrives, sizeof lpdrives, lpBuffer);RE: Concat an array of chars into another array or chars - gurlhackerclub - May 19, 2020 (May 19, 2020 11:36 AM)saltycracker Wrote: Why won't you just pass the array? The array name is the pointer address. Yea, I got this output. Code drives: C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\C:\I don't understand why, But I got it working. Thank you for your help though. RE: Concat an array of chars into another array or chars - SIM-3991524 - May 19, 2020 There is StringCchCatA aswell https://docs.microsoft.com/en-us/windows/win32/api/strsafe/nf-strsafe-stringcchcata RE: Concat an array of chars into another array or chars - k1r3n - May 19, 2020 You already using C++. You can use STL tools for working with strings. Simple example: Code #include <windows.h>In another case, you can use the tools that migrated from C. For instance: strcat |