Alex
c = getchar() ! = EOF ;
read char until end of stream
Massi
So it's like getchar() when u put it in the end of the code ?
Alex
for example you read chars from file in a loop. You need sign to stop, cause every file has its end. So you read entil EOF, this is end of file
Anonymous
c = getchar() ! = EOF ;
Write it like this: (c = getchar()) != EOF It's a one-liner from the C book, almost not-crazy because the while loop doesn't need a second fetch, which someone might forget... But nobody codes like that in real life!
Anders
/get cbook
Massi
thanks
𝚕𝚊𝚒𝚗𝚋𝚘𝚝.𝚜𝚌𝚖 🇺🇬
lloowen
Is there anyone in this group using Doom Emacs as their C++ IDE?
Pavel
/report not sure what this is, but doesn't seem to be related to C/C++
Pavel
klimi
:3
lloowen
I do
I'm new to Doom Emacs and I'm looking for any config examples to help me get the packages working to achieve the best C++ IDE experience. I know how to install packages but don't know how to configure them.
klimi
if you use doom emacs you just uncomment ;; cc in your init.el
klimi
run doom sync and you are good to go
lloowen
if you use doom emacs you just uncomment ;; cc in your init.el
Yes I've done that. I've installed, flycheck, RTags, irony and some other packages but cannot get them working.
klimi
what is the error?
klimi
maybe we should move to offtopic
lloowen
what is the error?
No errors, just the autocompletion and suggestions when writing C++ code doesn't work. That's all. One more question about compiling. Is there a way to see the output of a successful compile in the same buffer as were the errors appear? Instead of having to open up a buffer just to run the output file?
klimi
i compile in terminal
klimi
i haven't been doing C that much... i do haskell and python
klimi
next semester i have C so i will learn more
klimi
i would suggest you join doom emacs discord group (you can find the link on github)
Anonymous
XD
Anonymous
@JRandomGuy @unterumarmung https://www.reddit.com/r/cpp/comments/ldxkwt/iterator_invalidation_of_stdstring_view/gm9oyjd/
Anonymous
@JRandomGuy @unterumarmung https://www.reddit.com/r/cpp/comments/ldxkwt/iterator_invalidation_of_stdstring_view/gm9oyjd/
Anyway your question was kinda.. weird? Idk. I mean I don't like unnecessary state and mutations, I'd try to find a way of writing the code without the mutation
Anonymous
i mean what's the point of a non-owning view if you can't mutate it the way you want.
I'd try to get rid of the mutation + an iterator saving somewhere in memory
Sandro
Hello everybody, I'm C programmer, I'm using MS Visual Code but now I need to choose a good IDE (not editor) for Linux. My needs are: free license, dark mode editor and if it's possible a GUI interactive editor (but it's not mandatory). Thnx for supporting.
Sandro
I will try it, thank you!
Sandro
Đỗ
Cross platform: Atom, VS Studio Code. All support useful plugins, such as Lint, format code,+ integrated compiler or build script.
Đỗ
In Window, Visual Studio (Express version) lack many utiliies
Đỗ
and it's a bit of sluggish
Anonymous
In Window, Visual Studio (Express version) lack many utiliies
Lol, do you live in 2010? Express versions are old af and also don't exist for a long time
Đỗ
I prefer SubLime Text in both Window in Linux. Although it's a commercial software, but you can use it without register
Anonymous
I can't see any reason you use Sublime Text as a main tool to write code except your computer is way to slow.
Anonymous
vim for slow computers :)
Yep, but maybe the person wants GUI editor for some reason
Đỗ
SUblime ver 3.x is seem so cubersome, but 2.x is light and fast
Đỗ
and at least in Window it's open and navigate in the large prrj more quickly than VS
Anonymous
SUblime ver 3.x is seem so cubersome, but 2.x is light and fast
If Sublime 3 is cubersome for your computer, you definitely need some upgrade
Anonymous
and at least in Window it's open and navigate in the large prrj more quickly than VS
Because it's a simple text editor, not a full-featured IDE :)
Đỗ
some plugin and script still use in ver 2.x
Al
it looks this is going OT
Đỗ
and you're wrong, it's full feature IDE with many utilites, even design resources + GUI
Đỗ
what is exactly IDE in your idea? While you consider VIM is a IDE?
Anonymous
It's a text editor
Anonymous
> These are IDEs, good ones
Anonymous
And stop offtoping The final argument is that OFFICIAL website of Sublime states that it is a TEXT EDITOR
Anonymous
You are your best judge!! Manipulate your size😜 — #include <iostream> #include <string_view> using namespace std; int main() { std::string x = " this looks funny"; std::string_view y = x; std::string z {y}; cout << "String: " <<y.data() <<endl; cout << "Size : " <<y.size() <<endl; std::string_view::iterator it; int i=0; for(it = y.begin(); it!= y.end(); it++) { cout <<"Test-1: " <<i <<":" <<*it //<<"String: " <<i <<":" <<y.data() //## <<endl <<"Size-1: " <<i <<":" <<z.size() <<endl; //y.remove_prefix(*it); //#unhide# //y.remove_prefix(i); //#unhide# i++; } //////—-either-of-above-&-below—- //const int k=y.size(); /* for(int j=0; j<y.size(); j++) { cout <<"Test-1: " <<j <<":" <<y.data() <<endl <<"Size-1: " <<j <<":" <<y.size() <<endl; y.remove_prefix(j); } */ cout << "Last-Str1\t: " <<y.data() <<endl; cout <<"XX—————" <<endl; i =0; cout <<"String: " <<z.data() <<endl; cout <<"length: " <<z.size() <<endl; std::string::iterator itx; for(itx = z.begin(); itx != z.end(); itx++) { cout <<"Test-2: " <<i <<":" <<*itx <<"String: " <<i <<":" <<z.data() <<endl <<"Size-2: " <<i <<":" <<z.size() <<endl; z.erase(i, 1); i++; } cout <<"Last-Str2\t: " <<z.data() <<endl; cout <<"\nTypeX:"<<typeid(x.data()).name() <<"\nTypeY:"<<typeid(y.data()).name() <<"\nTypeZ:"<<typeid(z.data()).name() <<endl; return 0; } 🙃🙃
i don't see what you fixed. list of undefined behaviours - y.remove_prefix(*it); *it >= ' ' = 32 > 20 = y.size(); y.remove_prefix(i); y.remove_prefix(j); at some point i or j = 6 > y.size() = 5 at that point the erase loop - erasing contents invalidates iterators. itx++ uses invalid iterators, which is undefined behaviour. if you somehow fix that, the z.erase(i, 1); will eventually throw std::out_of_range because i keeps growing and z.size() keeps shrinking.
ⓐⓜⓘⓡⓡⓔⓩⓐⓦ
hi Can anyone help me define the lcd library in c++? thank you
KAMRUL
,
Aakash
i don't see what you fixed. list of undefined behaviours - y.remove_prefix(*it); *it >= ' ' = 32 > 20 = y.size(); y.remove_prefix(i); y.remove_prefix(j); at some point i or j = 6 > y.size() = 5 at that point the erase loop - erasing contents invalidates iterators. itx++ uses invalid iterators, which is undefined behaviour. if you somehow fix that, the z.erase(i, 1); will eventually throw std::out_of_range because i keeps growing and z.size() keeps shrinking.
I thought you will dig the example in details; Somehow.. y.remove_prefix(*it) — this is incorrect as iterator parameter is not supported like z.erase (itx, itx+1) or (i, 1); only integral is supported. That’s means remove_prefix(int); Secondly initializer list begin:end (range) don’t get update after use of remove_prefix as this is NOT supported by iterator operations; whereas erase updates the initializer list so both begin:end gets changed. That’s the reason you have invalidation with remove_prefix/suffix. Rest all is about programming. There nothing called undefined behavior; it’s just that iterator is using size 20; whereas remove_prefix isn’t capable (or not coded to update iterator initializers); but, erase is coded to work with iterator family. See the source, you will get to know all. 🙃
Programmer
why this compiler shows a wrong output for this program?: http://cpp.sh/26alq6
Pavel
It even shows a warning about that
Vlad
Order of execution is not specified
Programmer
This is undefined behavior
Exactly what makes it an undefined behavior? Logically the output must be 9. Other compilers have no problem with this.
Pavel
Exactly what makes it an undefined behavior? Logically the output must be 9. Other compilers have no problem with this.
Other compilers just implement it differently, there's no problem in any of the compilers
Anonymous
Other compilers just implement it differently, there's no problem in any of the compilers
not really. compilers are written for correct code. code that exhibits undefined behaviour is incorrect by definition.
Programmer
> Logically the output must be 9. What logic is that?
—a is 3, and it makes a == 3 and then a— is also three. Logically —a * a— must be 3*3