Работа с DWORDS

Я пытаюсь сделать строку DWORD Переменные типа. Как я могу объединить их?

    char* string;
DWORD a,b,c;

//abc will get some values herestrcat(string,a);
strcat(string,b);
strcat(string,c);

-1

Решение

Под c ++ вы можете использовать ostringstream:

#include<iostream>
#include <sstream>
int main() {
std::ostringstream os;
typedef unsigned long DWORD;
DWORD dw1 = 1;
DWORD dw2 = 2;
DWORD dw3 = 2;
os << dw1 << "," << dw2 << "," << dw3 << std::endl;
std::cout << os.str();

// os.str() returns std::string
return 0;
}

Ваш пример кода указывает, что вы можете предпочесть решение C, например:

char str[256];
sprintf(str, "%ld %ld %ld", dw1, dw2, dw3);

std::cout << str; // this is of course c++ part :)

пс. Я проверил это с g ++ 4.8

2

Другие решения

Других решений пока нет …

По вопросам рекламы ammmcru@yandex.ru
Adblock
detector