не важно как он выглядит. В какой кодировке вы его сохраняете?
UTF-8
SetConsoleOutputCP( 65001 );
Где найти статическую версию ImageMagick с хеадерами и либами?
Хотелось бы по возможности иметь бумажную версию такой книги, но "Практики программирования" в продаже уже нет
int i = std::cin.get();
CURLcode curl_easy_setopt(CURL *handle, CURLoption option, parameter);curl_easy_setopt is used to tell libcurl how to behave. By setting the appropriate options, the application can change libcurl's behavior. All options are set with an option followed by a parameter. That parameter can be a long, a function pointer, an object pointer or a curl_off_t, depending on what the specific option expects
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, postData.c_str());На с++ используя либу curl.
static CURLcode vsetopt(struct Curl_easy *data, CURLoption option, va_list param)case CURLOPT_POSTFIELDS:
/*
* Like above, but use static data instead of copying it.
*/
data->set.postfields = va_arg(param, void *); // Тут <-----------------------<<<<
/* Release old copied data. */
(void) Curl_setstropt(&data->set.str[STRING_COPYPOSTFIELDS], NULL);
data->set.httpreq = HTTPREQ_POST;
break;
#include <iostream>
#include <iomanip>
#include <cstdlib>
int main()
{
int a = 9;
int b = 4;
std::div_t result = div(a, b);
std::cout << result.quot << " " << result.rem << std::endl;
// Наверное это
std::cout.precision(1);
std::cout << std::fixed << static_cast<double>(a) / b << std::endl;
}
При компиляцииуже при выполнении
ifstream ifs("debug/text.txt");ifstream ifs("debug\\text.txt");ifstream ifs("text.txt");
Что может быть не так ?
что С++ и С можно строго разграничивать
1 Scope
1 This document specifies requirements for implementations of the C++ programming language. The first such
requirement is that they implement the language, so this document also defines C++. Other requirements
and relaxations of the first requirement appear at various places within this document.
2 C++ is a general purpose programming language based on the C programming language as described in
ISO/IEC 9899:2011 Programming languages — C (hereinafter referred to as the C standard) . In addition to
the facilities provided by C, C++ provides additional data types, classes, templates, exceptions, namespaces,
operator overloading, function name overloading, references, free store management operators, and additional
library facilities.
#include <iostream>
#include <map>
#include <string>
#include <iomanip>
using namespace std;
void swap(int& a, int& b)
{
int c = a;
a = b;
b = c;
}
struct info
{
int swapCount = 0;
int compCount = 0;
};
class Counter
{
public:
static Counter& Instance()
{
static Counter tsCounter;
return tsCounter;
}
info& getCount(string fn)
{
return callCount[fn];
}
void print()
{
for(auto& a : callCount)
{
cout << a.first << "\n"
<< setw(15) << left << "swap: " << a.second.swapCount << "\n"
<< setw(15) << left << "compare: " << a.second.compCount << "\n";
}
cout.flush();
}
private:
map<string, info> callCount;
Counter(){}
Counter(const Counter&) = delete;
Counter& operator=(const Counter&) = delete;
};
void mysort(int* a, size_t sz)
{
for(int i = 0; i < sz - 1; ++i)
{
int minIdx = i;
for(int j = i + 1; j < sz; ++j)
{
if(a[j] < a[minIdx]) minIdx = j;
}
swap(a[i], a[minIdx]);
Counter::Instance().getCount(__FUNCTION__).swapCount++;
}
}
int main()
{
int a[] = {2, 5, 6, 77, 1, 32, 45, 77, 12, 13, 14, 15};
mysort(a, sizeof(a)/sizeof(int));
Counter::Instance().print();
}
И вывод должен быть :
\n
Как так сделать ?
int main()
{
std::string s = "\\n";
std::cout << s << std::endl;
}int main()
{
auto s = R"(Raw string literal\n)";
std::cout << s << std::endl;
}Как сделать что бы можно было выводить строковые литералы?
макросы в С++
#include <iostream>
template<typename T>
auto sqr = [](T x)
{
return x * x;
};
int main()
{
std::cout << sqr<int>(3 + 0);
}//...
class __lambda_3_12
{
public: inline int operator()(int x) const
{
return x * x;
}
//...
};
//...
как правильно удалять произвольные элементы из вектора
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
vector<int> v{1, 0, 2, 0, 3, 0, 4, 0, 5, 0, 6, 0, 7, 0, 8, 9, 0};
v.erase(remove(v.begin(), v.end(), 0), v.end());
// или
// auto it = stable_partition(v.begin(), v.end(), [](int n){ return n != 0;}); // or partition
// v.erase(it, v.end());
for(int i : v)
{
cout << i << " ";
}
}или никак и надо использовать другой контейнер?

Но если использовать std::copy, то работать будет всё точно так же:
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
vector<wstring> words = { L"1", L"Goose", L"14", L"gas", L"/" , L"file10", L"file11" };
sort(words.begin(), words.end());
for(auto s : words)
{
wcout << s << " ";
}
wcout << endl;
wcin.get();
}
OUT: / 1 14 Goose file10 file11 gas