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;
}
//...
};
//...
видимо нужно ввести с клавиатуры фамилию автора
scanf ("%c", &surname);
У меня при вводе любой фамилии выводится "No"
if (begin->data.surname == surname && begin->data.year > 2000) // false false false false ...
{
year = begin->data.year;
pos = begin;
}
int year
???if (year <= 0 || year >= 2020) puts ("No");
while(begin) //пока в списке есть эл-ты
{
if(begin->data.year > 2000 && !strcmp(begin->data.surname, surname))
{
printf("Title : %s\n", begin->data.title);
}
begin = begin->next;
}
Translation limits
Even though there is no specific limit on the length of identifiers, early compilers had limits on the number of significant initial characters in identifiers and the linkers imposed stricter limits on the names with external linkage. C requires that at least the following limits are supported by any standard-compliant implementation:
какой компилятор из списка выбрать?
void ControlWin::on_tree_ClippingPlanes_itemClicked(QTreeWidgetItem *item, int column)
{
dialog_EditingTheClippingPlane* dl_EditingTheClippingPlane = new dialog_EditingTheClippingPlane();
dl_EditingTheClippingPlane->SetDate(
"0",
"0",
"0",
"Name");
if(dl_EditingTheClippingPlane.exec() == ...)
{
//...
}
delete dl_EditingTheClippingPlane;
}
В чем проблема?
if(dl_EditingTheClippingPlane.exec())
Shows the dialog as a modal dialog, blocking until the user closes it. The function returns a DialogCode result.
однако меня заверили, что и на 10 это возможно
I use mingw to compile userland part and NTDDK + VC6 to build sys driver.
как правильно удалять произвольные элементы из вектора
#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, то работать будет всё точно так же: