《K•r•e•m•e•l》
Write a function that produces output according to a format.
Prototype: int _printf(const char *format, ...);
Returns: the number of characters printed (excluding the null byte used to end output to strings)
write output to stdout, the standard output stream
format is a character string. The format string is composed of zero or more directives. See man 3 printf for more detail. You need to handle the following conversion specifiers:
c
s
%
You don’t have to reproduce the buffer handling of the C library printf function
You don’t have to handle the flag characters
You don’t have to handle field width
You don’t have to handle precision
You don’t have to handle the length modifiers
\Device\NUL
\Device\NUL
Or maybe copy printf function from libc source code
klimi
well you just create tcp connection and then send the data
klimi
well you can let the dns get the ip
klimi
https://stackoverflow.com/questions/30470505/http-request-using-sockets-in-c
klimi
you have written that you need google.com
Richard Luo 🐱
struct A {
const std::string a = "dwda";
};
int main()
{
std::map<std::string, A> map;
A a;
map[a.a]=a;
return 0;
}
The above code can not compile because the const will delete = operator. How can I define a readonly property without affecting the = operator like in other lauguages?
klimi
well then yes, you need to know what server you want to connect
/
/
what is the interpreter_wrap_int64_t() call for?
Vez_Man
Recommend a very good c programming site or book for beginners please
Anonymous
struct A {
const std::string a = "dwda";
};
int main()
{
std::map<std::string, A> map;
A a;
map[a.a]=a;
return 0;
}
The above code can not compile because the const will delete = operator. How can I define a readonly property without affecting the = operator like in other lauguages?
You can't do that. Think about what it means for operator= for such a class. If you need a class with read-only properties to be stored in a map, you have different alternatives
1) don't make the read-only property a const and expose only a getter to the public. As a class designer then, you should be careful not to change this property anywhere from within the methods of the class
2) you can make the properties const but in this case define your own overloaded operator= to ignore these properties and just return *this from within the method. Here you will have to worry about the semantics of your class if you have non readonly properties as well in the class. What does it then mean for only these non read only properties to be copied while ignoring the read only ones.
3) Instead of storing the objects of this class in the map store a pointer or reference to the objects of this class in the map. Here you will have to worry about the lifetime of the map and the contained objects and ensure there is no access to a destroyed object.
4) You dont store these objects in a map and instead design your own facade class which manages these objects and returns instances of them as required.
Richard Luo 🐱
Back Track
Hello guys just wondering how can I change the bool size in a struct which is by default 8 bits to higher bits like 16 or 32 bits does anyone have an idea?
mito
Alireza
DWORD GetModuleFileNameA(
[in, optional] HMODULE hModule,
[out] LPSTR lpFilename,
[in] DWORD nSize
);
what is [in] and [out] ??I cant understand
Stanislav
Stanislav
https://docs.microsoft.com/en-us/cpp/code-quality/understanding-sal?view=msvc-170
Stanislav
Alireza
Stanislav
u mean [out] will be return?
no, inside function in [out] function writes something, and then return you error code
for example
char name[256];
auto res = GetModuleFileNameA(nullptr, name, sizeof(name));
this returns path to your process
res - return value from function (errorcode or successfull)
[in, optional] nullptr - for this function it is current process or maybe handle for another process
[out] name - function write here the path to process
[in] sizeof(name) - size of name buffer
Stanislav
pretty easy
Alireza
Back Track
Why though?
don’t really know it is the silly assignment requirement 😑☹️
Sam-tlt.btc
#include <stdio.h>
int main (void)
{
 unsigned int counter;
 int grade;
 int total;
 int average;
 
 total = 0;
 counter = 0;
 
 printf ("%s", "Enter the grade, enter (-1) to end: ");
 scanf ("%d", &grade);
 
 while (grade != -1) {
     total = total + grade;
     counter = counter + 1;
     
     printf ("%s", "Enter the grade, enter (-1) to end: ");
     scanf ("%d", &grade);
 }
 
 if (counter != 0) {
     average = (float) (total / counter);
     
     printf ("The average of the grades is: %.2f\n", average);
 } else {
     printf ("%s", "No grades were entered");
 }
}
Sam-tlt.btc
Hi guys, wrote a C sentinel controlled program for determining grades in which the counter will be dynamic, I tried wanting to get my ans in float but it's only giving me 0.00 while if I want the answer in int it do gives but with no decimal stuff, any hint on the solution to this?
Sam-tlt.btc
Anyone?
klimi
well but you have your average declared as int, so it cannot store float
Sam-tlt.btc
Sam-tlt.btc
Thanks
Sam-tlt.btc
I'll check that
Pavel
Hm, what is the easiest for C++ way to do inter-process communication with another app (written in Rust or go, haven't decided yet)? It needs to be a portable (Windows/Linux/Mac, but both processes are on the same machine always).
Details: I want to make a separate app (that Rust or go part) that will spawn instances (processes) of my C++ app and send/receive data to/from these processes.
pavel
Khadija
Hi. I have an array A of N length containing strings ni need number of good pairs of strings that can be formed
Khadija
Class solution {
Public static long getnumbergoodpair(int n , string[]A) {
}
}
Anonymous
Kumar Chandra Sheo
Hey I just started coding anyone tell me any good youtube channel where I start learning C++ as a complete beginner
Suraj
Ибраги́м
https://gcc.gnu.org/wiki/Visibility
St
How can you send a file to someone, somehow like an app, once the person installs and open, it instantly sends a certain message to all contacts of the person
I
Which code is used there, please share, someone has done that to me
klimi
St
ɛ n h ᴀ n c ɛ ґ 🧟♂️
Hey guys i have this code in a header file
class SinglyLinkedLsit
{
private:
struct Node{
int Value;
int key;
Node *next;
};
Node *Head;
};
And in it’s implementation file I’m trying to create a function that returns a pointer of type Node but my compiler keeps giving the error “Node does not name a type”.
Can anyone help me stop this error?
(I tried googling but I’m not getting similar issues as mine)
`` 🇫🇷 ;; ce serai ta blonde ce soir, si c'est ce que tu aimes
St
How can someone read a code in an app?,
St
André
As in?,
Your question was so vague there is literally no other answer for it
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
How can someone read a code in an app?,
I warn you I don't know the answer to both of the following, but it may help much more experienced programmers in order to answer your question:
1) Read code as in "see the code behind the app"?
2) Read code as in "code reader app" like Kodek?
Aryan
#include<bits/stdc++.h>
using namespace std;
void printf(int ind,vector<int> &ds,int arr[], int n){
if(ind == n){
for(auto it: ds){
cout << it <<"";
}
cout << endl;
return;
}
ds.push_back(arr[ind]);
printf(ind+1, ds, arr,n);
ds.pop_back();
printf(ind+1, ds, arr,n);
}
int main(){
int arr[]={3,1,2};
int n=3;
vector<int> ds;
printf(0,ds,arr,n);
return 0;
}
why am i not getting any output in this?
klimi
#include<bits/stdc++.h>
using namespace std;
void printf(int ind,vector<int> &ds,int arr[], int n){
if(ind == n){
for(auto it: ds){
cout << it <<"";
}
cout << endl;
return;
}
ds.push_back(arr[ind]);
printf(ind+1, ds, arr,n);
ds.pop_back();
printf(ind+1, ds, arr,n);
}
int main(){
int arr[]={3,1,2};
int n=3;
vector<int> ds;
printf(0,ds,arr,n);
return 0;
}
why am i not getting any output in this?
k11m1@k11book/tmp$ ./test
312
31
32
3
12
1
2
klimi
#include<bits/stdc++.h>
using namespace std;
void printf(int ind,vector<int> &ds,int arr[], int n){
if(ind == n){
for(auto it: ds){
cout << it <<"";
}
cout << endl;
return;
}
ds.push_back(arr[ind]);
printf(ind+1, ds, arr,n);
ds.pop_back();
printf(ind+1, ds, arr,n);
}
int main(){
int arr[]={3,1,2};
int n=3;
vector<int> ds;
printf(0,ds,arr,n);
return 0;
}
why am i not getting any output in this?
you sure you are executing good executable?
Aryan
Nils
unsigned toUnicornProt(unsigned prot) {
unsigned fres = UC_PROT_NONE;
fres |= unsigned(bool(prot & UNIBOARD_PROT_READ)) * UC_PROT_READ;
fres |= unsigned(bool(prot & UNIBOARD_PROT_WRITE)) * UC_PROT_WRITE;
fres |= unsigned(bool(prot & UNIBOARD_PROT_EXEC)) * UC_PROT_EXEC;
return fres;
}
Does this look like valid code? Am I right that bool will make sure the value is either 1 or 0?
Pavel
Nils
Lxjxjxhks
C++23
hey could you let me know how to update my compilar to g++23
Максим
You can use following code c++11(or range version, if you're using c++20):
#include<algorithm>
#include<string>
std::string s = "aeiou";
if( std::any_of(s.begin(), s.end(), [](char c){ return c == 'e';}) )
St
klimi
Depression, lack of motivation, disconnection to the reality and other stuff
chakiwinja
Abdelghani
hey everyone I'm looking for intermediate-level C courses(free ones) if available of course.
Rukky
Hi please I’m new to tech and I want to learn C…I will really appreciate any resources that explains it in a very simpler terms
Bhaskarjyoti
hii
klimi
Alireza
why my visual studio does not know wstring?
Alireza
i tried it
Alireza
but it didnt work
Alireza
oh yes I thought I was applying` using namespase std`
Alireza
tnx
Alireza
std::string BinRes::getAppLocation()
{
TCHAR szPathName[128];
std::string strPath;
GetModuleFileName(NULL, szPathName, 128);
strPath = szPathName;
int slashPos = strPath.rfind('\\');
if(slashPos == strPath.npos)
throw "Unable to get exe location";
strPath = strPath.substr(0, slashPos);
return strPath;
}
strPath = szPathName; in this line I have this error:
Error (active) E0349 no operator "=" matches these operands
what should I do ? I am not familiar with winbase syntax:(
klimi
Alireza