Ask coding questions

← Back to all posts
Odd console output.
0068930

I'm trying to make my very own bootleg notepad, but I'm running into an issue(not an error, but just an issue).

The code is simple and basic, but I think I'm having compiler issues. For now, the code asks for a password to save all your notes in and then asks for confirmation.

If you choose to save your password the screen clears and asks for the name of your first note.

But when you enter your note name, the console outputs something like "bash: command not found". I wonder what's going on with it; can you help me, please?

Voters
0068930
Comments
hotnewtop
Whippingdot

Hey ima try helping you - one sec ima fork the repl and tell you what is wrong

0068930

Thank you!

Whippingdot

hey unfortunately i couldn't figure out the problem with the getline statement not working (on my vs code it just doesn't let me enter an input) but cin works fine enough for me...why don't you just use [email protected]

0068930

std::cin worked for me too; I was just trying to be fancy by using getline! Compilers are weird; methods only work when they want to. lol.
Also, do you think my code is well structured? Thank you for your assistance!

Whippingdot

In the code I sent, it has better formatting and it looks better overall. Maybe copy and use that code? @0068930

0068930

I found limitations with std::cin. std::cin only takes the first word in a sentence with spaces. If I use underscores instead of spaces, it will register the whole sentence. Should I work around this and not allow spaces in the note name? @Whippingdot

Whippingdot

hmmm... maybe you can make a for a loop which converts underscores into spaces if you want to. You can make it so it loops through the whole string:

and make it so that there is an if statement that checks if the character is an underscore, and you can have an incrementing variable starting with 0 too so you can get an index, and if the if statement finds out that the character is an underscore then you can use the index to replace the underscore in the string with a space. I don't know if you understood but for now I will not give you the code cause I want you to try it by yourself
@0068930

Highwayman

@Whippingdot
Don't forget about references. (no need for an index)

Just makes things simpler.

Also, you could try doing std::cin << std::flush; before the second std::getline(). I've also encountered this error with std::getline() before, and If I remember correctly that fixed it. It's something to do with std::getline() swallowing the \n at the end or something...?

Whippingdot

bruh i have no idea what your program means (like i know what a reference is but what does that change?) @Highwayman

Highwayman

It is a reference to each item in the list, so if I did

as you can see, it's actually modifying the elements in the array. it's the same exact concept as passing by value vs. passing by reference:
for(auto it : arr) gives you just the value, not the element (=passing by value)
for(auto& it : arr) gives you a reference, so the actual element (=passing by reference)

hence, these two pieces of code are identical:

@Whippingdot

Whippingdot

kk
thanks you just reminded me what references were! @Highwayman

Highwayman
0068930

Thank you for your help, bro. How'd you get so knowledgeable?
@Highwayman

Whippingdot

by learning coding lol @0068930

Use codecademy or something to learn coding and if you really like it ask your parents to pay for some online service so you can learn coding properly (like for your birthday ask them to pay for Codecademy pro or udemy or something)

0068930

I know. All I'm saying is how do you REALLY learn it. Just like how almost everyone knows English but not everyone can write a book. At least a good one. @Whippingdot

Whippingdot

Oh, I don't know that... @0068930

0068930

Hmm...Sorry, that was my fault. Let me phrase it better, bro. I mean how do you bridge into more complex stuff like learning multiple languages? @Whippingdot

0068930

Thank both of you! I should've thought about using references long before I asked this question, but you live to learn!

I used the ASCII chart to solve the problem since printed characters are just abstractions of numbers.

I check to see if the character in question is in the alphabet according to ASCII, If it's not, change it into an
underscore.
Thank you for providing an alternative interpretation of my code!

Whippingdot

That isn't complex. If you learn the basics of one language, the same is carried through almost all languages. It becomes simple to learn other languages too. Just try another tutorial or course and you will see that learning another language after one is very easy. @0068930

0068930

Well, to be honest, I was just using that as an example. Maybe it's a bad one. Computer basics apply to all languages. I was just asking about how to make that leap from basic code to making compilers, building game engines, and stuff like [email protected]

Whippingdot

Finally, I have understood. To be true I also don't know tho cause I want to learn how to build games but I haven't started yet. I probably will run into the same problem as you... @0068930

Sorry for the ping but @OldWizard209 can you help this dude out? You seem to be very WIZE lol but seriously you do know lots of knowledge in the realm of code