When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
210 messages ยท Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
Loop.
What is the assignment exactly?
you have a lot of repetition insert/begin/replace/find, you could save characters by putting all your arguments in arrays and then looping through them
you could also precompute all the z[0].find("#"), they will be fixed
and if you don't need both <array> and <vector>, you can drop one include
Can you send the .txt file?
of the provided file
lol, no you don't
hmm, strange
I think you could have all the "turtle doves", "french hens", etc stored in a vector, then loop in reverse and add the number in the loop
If you have fmt you could do "On the {} day of christmas my true love..."
Nested for loops should make it pretty easy
im trying to do a array loop but idk how i could call lines that come after others in the array part before others
cuz in my for loop, im thinking of incrementing a variable and outputting thhat many strings of the array
but array gets output from a b c for eg
i want c b a
but i want to add a string in place D next
not A
for (int i = 1; i < 13; i++) // day count
{
for (int j = i-1; j >= 0; j--)
{
printindex(j);
}
}
Smth like this? Idk
Iterate through the thing in reverse
Also since it's all fixed anyway, might as well hardcode them
For the array printing?
yeah
What did you not understand
try adding what i told u originally, adding loops, how do i ncrement the day @ {} ?
With a loop
like how do i correct this {cout << x,num[0];
?
sorry im maiing youu so confused
making*
also yeah the code i sent has some errrors to fix but i want to fix this frist since you are here rn
i would use 2 string variables
cout << std::format(x, num[i]); ?
Yes. Include <format> and use c++20
replace x with the text
lmao
Oh yeah, might as well just use the literal since you're using it once
ohh so i get rid of "string x=..." line
Me omw to delay c++29 to 2030
Based as can be
format is c++20 i believe
wow so my prof scuffed me?
like what he said
Oh then just use fmt::format
umm did you run it with the flag -std=c++20
Include the fmt header instead of <format>
tbh your prof won't run it with the argument so probably shouldn't use it
fmt::print(blah, blah2) is shorter than std::cout<<std::format(blah,blah2) as well
#include <format.h>?
prob shouldnt use..?
what?
In your origibal post you have <fmt/format.h>
don worr ab it
true !
i did but then im re writng everything
and even got rid of all the includes accidentally
so i was confussed
but i added it back
I mean, that's the header you should be using
and still erorr
Can you send the line where you used the fmt
cout << fmt::format("\n\nOn the {} day of Christmas \nmy true love sent to me:", num[i]);
It looks like youre missing the fmt.c or whatever that's called
It should be compiled and linked
oh god
what is that now....
wait
one sec
nvm
i thought since im writing this code in a standard file, one that i created for myself, that if i copy paste the code into the file the prof provided, that perhaps it would run in his provided "template" cuz he may have added stuff from the libraries that we may have needed
It's a compiling thing
so compiler is dumb?
This?
From this yt https://youtu.be/tUZAnPT5Zvc?si=VsGvXa7h7TYx_gbY
The fmt library is an awesome C++ library for printing and formatting text. I highly recommend using it in your projects.
For more information about this library and to read the documentation https://fmt.dev/latest/index.html
==== Awesome Links ====
๐ฃ Discord: https://discord.gg/XyhP8uYPTS
โ๏ธ Github: https://github.com/TheBuilder-software
๐ Pa...
Uhhh i wouldnt trust that
Grab it here ^^
Damn Alr
so i have to take the zip i found from ur link thing and somehow insert into the compilers files?
oh
didnt read that
well more like
didnt know fmt was a didfferent library
ive never used it
i see
now im lost on what to do yay
si there a slower way to do what we wanted to do?
ya
str1 = "\n\nOn the ", str2 = " day of Christmas \nmy true love sent to me:";
in between put in a variable
for the num
num[i] yeah
probably simpliest way
wdym
nice
cant type in the code cuz its freezin up but yeah
um not at all
idk why its doing that
it shouldn't lag lmao
werid
oh btw, this is as small as it can get right?
i cant shorten ?
hmm.. when i try running this, it really struggles
Undefined behavior occurs when you violate rules specified by the language. For example: Reading uninitialized memory, performing out-of-bounds memory access, signed integer overflow, and race conditions.
int i; // default init,
// indeterminate value
while(i < 10) {
printf("%d\n", i++);
}
int arr[10];
for(int i = 0; i < 20; i++) {
arr[i] = i; // [i] out of
// bounds
}
Compilers are not required to provide warnings or errors about UB. Often it is undetectable at compile-time. Performing actions which are UB can render your entire program's behavior undefined, leading to anything from crashing to summoning Eldritch Abominations.
Sanitizers can help identify UB. For more info, look into address sanitizer (ASan) and undefined behavior sanitizer (UBSan). See !howto asan
hm thats a problem?
it doesnt feel like it to me...
so i just move everything into the for looop..?
except the array itself
staring into its soul rn
yes...
Yeah, remove the -1
it's not 100% correct, make sure to compare the texts
hmm why was that there in the first place?
dunno, u wrote it
yeah, remove the and
ig its on me for not noticing
true
this is so embarassing man
@marsh fog
Please don't delete forum posts. They can be helpful to refer to later and other members can learn from them. In the future you can use !solved to close a post and mark a post as solved.
@marsh fog just plain embarasing dawg
bruh what
deleting your message too
LMAOOO
?
bruh what
@cloud cliff whyd u go quiet
i dont understand what makes u think this is embarassijg
: )
@cloud cliff bro npc
its more embarassing seeing someone who clowns on another for no reason
the fact that u are also here in this server doesnt make u less embarassing than me @cloud cliff
i came for guidance... you for clowning?
tf?
the audicaty man
no responses?
@cloud cliff
stop hiding dawg
u done talkin dawg?
your arguments are so strong wow
Scroll up if you think he copied me? There's clearly a lot of discussion going on.
As well as the for loops are not similar to mine 8)
mfs arguing over code ๐ ๐