Anurag
Actually this is what I'm intending to do: I have a string variable and I want to convert the string inside it into a raw string
Anurag
Actually this is what I'm intending to do: I have a string variable and I want to convert the string inside it into a raw string
There are a few \ (backslashes) in my string and I want to treat them as normal characters
Anonymous
How to convert a string input to raw string in cpp?
C++ supports only raw string literals. Treating special characters as normal in a user inputted string is within your own purview. You can do it manually by escaping each special character with a backslash. I am assuming that you are doing so because this input is being passed somewhere like a shell command line which has its own escape mechanism.
Ибраги́м
https://www.youtube.com/watch?v=VpqwCDSfgz0
后藤
How can i learn cmake for accustoming to compiling with the gcc command?
Anonymous
How can i learn cmake for accustoming to compiling with the gcc command?
You mean you want to CMake to use gcc as a compiler? CMake will determine the compiler to use automatically during the configuration stage (the stage before the build generator). If it didn't choose GCC and you want to force it to choose GCC, you can do it by passing -DCMAKE_C_COMPILER=<path to gcc> -DCMAKE_CXX_COMPILER=<path to gcc> when you use CMake to generate the build file i.e. cmake -DCMAKE_C_COMPILER=<path to gcc> -DCMAKE_CXX_COMPILER=<path to gcc> -S <source tree> -B <build tree>
Anonymous
Not that point. I used to compile c++ file with command like gcc test.cpp -o test but now i need to write cmakelists.txt. So i want to find a document to learn how to write cmakelists . And it's best to explain every line of cmake code by corresponding to a parameter for gcc.
Read a good book on CMake or read their documentation online. Though CMake's documentation is great, it is hard to get started with their documentation as it is not very beginner friendly. I would suggest reading some good books or online tutorials. I don't have any recommendations because I learnt CMake at work and I had colleagues to lean on.
Anonymous
Not that point. I used to compile c++ file with command like gcc test.cpp -o test but now i need to write cmakelists.txt. So i want to find a document to learn how to write cmakelists . And it's best to explain every line of cmake code by corresponding to a parameter for gcc.
And CMake is a build generator. Every line in CMake doesn't translate to an equivalent line for gcc,gas or ld. Cmake does a lot of things like configuration checks, code generation, custom target creations, dependency analysis, fetching dependencies from external sources, locating packages, running tests, installing packages and so on. Some of the tasks above are not manually done by CMake but CMake generates the build script which does all this. At a high level, the commands in CMake (the functions and macros) may translate to multiple calls to the compiler et al or may not even involve a call to any of the compiler tool chains.
Rehan
Swapping in linked list Anyone tells?
Anonymous
Swapping in linked list Anyone tells?
It's easy for doubly linked list
Rehan
It's easy for doubly linked list
How can you send the code
Rehan
Or for single linked list
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
[C language] Hi, I have a file divided into "sections" like this: A1B2C3 //Stuff B4V6N8 //Stuff2 M9N8B5 Let's imagine I want to cancel Stuff2, which may be several lines. Now, in my software I'll make sure the file poiner is set at the beginning of stuff 2. Now, reading on stack Overflow I understand that the only way to do so seems to be copying everything you need on another file, then scrap the old one and so on. Problem is: this file is HUGE, and this thing happens very often... so, I think this method is too slow and heavy for my code, is there another way to do so?
Gilded
How to automatically correct full code syntax in codelite c workspace????
Gilded
Pls anyone say asap
Sleeves
Hey guys I’m studying C programming under windows
Sleeves
What is a modern day equivalent of : Finogenov K.G. "Win32. Basics of programming
Khadija
Hi hope you are doing well I have a question … Please why we use Void function for sort tables ?? Selection sort , bubble sort ……?
Khadija
You can find a great courses in udemy or udacity even in YouTube … And try to start with c because it is basic then go to c++ … Good luck
Khadija
… try to solve problems by C and do some projects like files .. management system …. Etc Then go to C++ Btw ( C++ is simple then C ) but just when you start learn a language try to finish it .. Good luck
Unk
How can i change hier malloc with new ? int d; cin >> d; double** matrix; matrix = (double**) malloc(sizeof(double*)*d); I do that so but it‘s wrong: *matrix = new (double*d)
Pavel
How can i change hier malloc with new ? int d; cin >> d; double** matrix; matrix = (double**) malloc(sizeof(double*)*d); I do that so but it‘s wrong: *matrix = new (double*d)
in contrary to malloc that manipulates with raw memory, "new" needs to know all the type information of the things you want to construct. In this case you need to specify what is the double used for. E.g. if you want an array double* matrix = new double[d]; if you want array of pointers, to arrays that will be double** matrix = new double*[d]; etc. depending on what you want
Pavel
For matrices what I saw people usually do is they allocate an array of size M*N and address them using them with something like (x+y*M).
neovstan
Don’t start from C. Please. There’s a lot of the bad habits of C that developers use in their C++ code
🇺🇸
Hello everyone Can someone help me to write code which will able to demonstrate specific pattern
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Hi hope you are doing well I have a question … Please why we use Void function for sort tables ?? Selection sort , bubble sort ……?
Let's assume you are sorting a list. You will want to pass the head of the list as a double pointer, that is to say, imagine this is your head: Struct node *head; Well, when summoning bubble sort (imagine you are in function main and then summon function bubble) you'll pass bubble(&head). This means that the node you pass (head) it's a copy, but the address is "real". Therefore, everything you do in bubble will be effective also in main and every other function. If you passed head, bubble would still modify stuff, but it would actually be a copy of the head. Well, since you modify the real thing, then you don't need to return anything. The function will do stuff, but you operated directly on the address where this stuff is stored, therefore, when control is returned to main, you'll keep using head, but the list will be sorted different. If you passed bubble(head), bubble would sort a copy, then control is returned to main and you'll be using the non sorted list. In this second version, you would need bubble to return a pointer:struct node *blubble(struct node *node); Therefore in main you'll do this: Struct node *new=bubble (head), then you'll use new and you'll have the sorted list, head and you'll have the non sorted one. Anyway, the first way is the best one
E🦈
Can everyone explains me how loops i j k or i j k l works?
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
What do you mean by "cancel stuff2"?
Stuff2 is like 100 lines of text. In my implementation it's a text message, and the user wants to delete it from a web site. For this project I'm using a file as a backup for data persistence, therefore if the mex is deleted from the web site, it should be deleted from the backup file, too
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Well they basically are what makes C such a powerful language imho. I'm not a senior coder, therefore I'll not deep any further in to this question, as I might tell you wrong stuff, but check on YouTube: you shall find hundreds of videos explaining the difference between (that's what you are looking for in the end) passing arguments from value rather than from address and so on, and they surely know better than me how to make sure you understand this crucial aspect of C
Anonymous
Stuff2 is like 100 lines of text. In my implementation it's a text message, and the user wants to delete it from a web site. For this project I'm using a file as a backup for data persistence, therefore if the mex is deleted from the web site, it should be deleted from the backup file, too
Well if you want text deleted from a file, you don't have much of a choice. Since it is a backup copy,you also want to be extra careful. So copying to a new file and writing only the changes you need is the only option. You shouldn't be using a text file as a backup for this case. A document database like MongoDB would be the best fit for this use case.
𝕷𝖔𝖗𝖊𝖓𝖟𝖔
Well if you want text deleted from a file, you don't have much of a choice. Since it is a backup copy,you also want to be extra careful. So copying to a new file and writing only the changes you need is the only option. You shouldn't be using a text file as a backup for this case. A document database like MongoDB would be the best fit for this use case.
Well, if it's the only way, so be it! Btw, yes, the text file is not good for backup, but it's an Operating Systems project in university, therefore I still don't know how to use this. But in reality it's interesting, even though the prof doesn't expect us to use anything else than text I'm interested in making project much more robust, so I'll give it a look
ossset
Hey! I do have a newbie question here - can't really get why the string is not getting printed, can i ask someone to point out my mistake? https://pastebin.com/uF7fiDfn
neovstan
Don’t start a programming languages’ trip from C, guys
Гулящий
Well, that was a wise decision.
Gilded
All questions no answering people online today 😞
Gilded
I didn't study im unable to connect concentrate
● Igor
I'm trying to format this number 2006.008 to show as _______+2006.01 so i did this: cout << setfill('_') << setw(15) << fixed << setprecision(2) << showpos << 2006.008 << endl; but the sign is always before the _, even if i change the order of the parameters... +_______2006.01
● Igor
nevermind, i just needed to use << right <<
hello
hi, can you use a file pointer name that is delared in one file in another file , using makefile or anything like that?
Hello, How to implement this behavior in compile time: check whether a class owns a member, if does, use it, otherwise check another member, if does, use it, otherwise raise compile error? I am currently trying this, but it does not work: static constexpr Name Contract_1 = []() constexpr->Name { if constexpr (requires() { InternalName<Name>::Contract_1->Name; }) { return InternalName<Name>::Contract_1; } else if constexpr (requires() { InternalName<Name>::Default_1->Name; }) { return InternalName<Name>::Default_1; } else { static_assert(false); } } ();
𝑪𝒐𝒃𝒓𝒂
from where can I get practice questions ?
𝑪𝒐𝒃𝒓𝒂
HackerRank, LeetCode.
Hacker rank’s first question is hard for me 🥲😓
Joo
I want to start doing projects using c++. Can I get any recommendations??
Joo
What recommendations do you want?
Any problem I can use C++ to solve
klimi
Any problem I can use C++ to solve
and what is interest to you? writing kernel drivers? programming embedded? coding webservers? gamedev? some graphics utilities?
klimi
Kernel drivers, programming embedded and coding webservers
then go for it, I don't think you need more recommendation if you have that info
klimi
Ooh okay
but if you have question, feel free to ask
Joo
Actually, I wanted a site recommendation I could find some projects to do
klimi
Actually, I wanted a site recommendation I could find some projects to do
site recommendation? well... you could look at github and maybe fix some issues if that is what you are asking? (not sure if i understand you correctly)
Joo
Oooh okay
Гулящий
Oooh okay
You want a real big project or would you like to focus on small exercises for now?
Joo
Small exercises bro
Гулящий
Small exercises bro
https://leetcode.com/
It is not clear what you want to do here. Do you want to check if a class has a type alias Name in it at compile time?
Sorry, Name is a template parameter. I want to implement this: template<typename Name> struct name_trait { static if ( requires(){internalname<Name>::contract1; } ){ static constexpr Name contract1 = internalname<Name>::contract1; }else{ static constexpr Name contract1 = internalname<Name>::default1; } } i dont know whether i explain clearly now with "static if"
Sorry, Name is a template parameter. I want to implement this: template<typename Name> struct name_trait { static if ( requires(){internalname<Name>::contract1; } ){ static constexpr Name contract1 = internalname<Name>::contract1; }else{ static constexpr Name contract1 = internalname<Name>::default1; } } i dont know whether i explain clearly now with "static if"
Internalname is an empty template struct, which is designed to let downstream user specialize it, user may define contract1, or default1, I want to check if contract1 is defined, if defined, use it, otherwise use default1. if both of them are not defined by downstream user, raise compile error here.
Pietro
Hello, is there a way to format the console output? (Example: making the text of a single line bold, or change the font size). And if not, how should I format it? Sorry for bad english, thanks to all who will reply.
hello
Hi i have 2 files connected via header and because of that the second file compiles before my main file and all the variables in it which i have definitions for them in my main file, what can i do? I compiles and says the variables are undeclared
Anonymous
Hey all will u please help me in c++ I have project of calculator Is like Suppose I am doing the addition of the two number a+b=24 and the suppose the answer is 24 then after that from the user to ask that whether you want to continue with answer and add another digit in answer and then again add and if not then say no and continue to the next part
Anonymous
How it would be
Anonymous
I hve written half of the code
Yui
https://godbolt.org/z/36bvWcnEd why does it still expect a type🤨
Yui
oh i change the order of declaration it fixed..
Yui
another question: why must I specify the namespace of database template parameter, like this https://godbolt.org/z/P67h81n6W
Yui
...my bad, just glanced that the local variable name is the same as type name
labyrinth
github trending page seem to sucks
labyrinth
lack of real projects
mack
#include <iostream> using namespace std; class MyClass { public: void DisplayMessage(const char *Text, unsigned int Type) { cout << "Message:Text=" << Text << endl; cout << "Text=" << Type << endl; } void DisplayMessage(const char *Text, int Type) { cout << "Message:Text=" << Text << endl; cout << "Text=" << Type + 10 << endl; } }; int main() { unsigned char value = 0; MyClass my; my.DisplayMessage("Hello", value); } why run second DisplayMessage?
mack
The answer is : Message:Text=Hello Text=10