Post AVWW5USnVSj8wUA3LE by kirby@freespeechextremist.com
 (DIR) More posts by kirby@freespeechextremist.com
 (DIR) Post #AVWVV02h8Lo4AUYGbw by kirby@freespeechextremist.com
       2023-05-10T20:41:37.975143Z
       
       1 likes, 0 repeats
       
       I did something along the lines of thisfor (int i =0; getchar() != EOF; i++)      string[i]it only worked when I pressed enter
       
 (DIR) Post #AVWVW4vaSIvnbqk2Km by kirby@freespeechextremist.com
       2023-05-10T20:41:49.673375Z
       
       1 likes, 0 repeats
       
       Oops forgot the semi but you got the point
       
 (DIR) Post #AVWVWdgDFSQhOIokjI by kirby@freespeechextremist.com
       2023-05-10T20:41:55.751141Z
       
       0 likes, 0 repeats
       
       Get***
       
 (DIR) Post #AVWVYpzOSAa69ApzVY by 7666@comp.lain.la
       2023-05-10T20:42:19.207350Z
       
       1 likes, 1 repeats
       
       @kirby cc @get
       
 (DIR) Post #AVWVcy8685eeYIsYcK by kirby@freespeechextremist.com
       2023-05-10T20:43:04.388828Z
       
       0 likes, 0 repeats
       
       wait fuck I forgot to actually type out printd
       
 (DIR) Post #AVWVe0Ph7jl3vPbVvk by kirby@freespeechextremist.com
       2023-05-10T20:43:15.630606Z
       
       0 likes, 0 repeats
       
       PRINT FWHAT IS GOING ON
       
 (DIR) Post #AVWVepXF3R6ATaWlH6 by lina@eientei.org
       2023-05-10T20:43:07.885970Z
       
       0 likes, 0 repeats
       
       @kirby get***e?
       
 (DIR) Post #AVWVgfeclKjyPUrGbo by kirby@freespeechextremist.com
       2023-05-10T20:43:44.518930Z
       
       1 likes, 0 repeats
       
       @lina s/got/get/
       
 (DIR) Post #AVWVmLFzVoBkt22Z5E by p@freespeechextremist.com
       2023-05-10T20:44:46.026441Z
       
       2 likes, 0 repeats
       
       @kirby getchar() is buffered.
       
 (DIR) Post #AVWVog9ylYXIINLJLM by kirby@freespeechextremist.com
       2023-05-10T20:45:11.368599Z
       
       1 likes, 0 repeats
       
       @p Why
       
 (DIR) Post #AVWVpPU4FiLKri5UP2 by lina@eientei.org
       2023-05-10T20:45:08.148166Z
       
       0 likes, 0 repeats
       
       @kirby getgle
       
 (DIR) Post #AVWVvdUn4QHA3jOW7U by eris@rdrama.cc
       2023-05-10T20:46:26.473428Z
       
       2 likes, 1 repeats
       
       @kirby @p So that you can backspace when writing input without each program having to write support for it
       
 (DIR) Post #AVWVyt2PjzbP8Dfhw0 by p@freespeechextremist.com
       2023-05-10T20:47:02.054706Z
       
       2 likes, 1 repeats
       
       @kirby Syscall overhead.  You can read a single byte from FD 0 if you want.char c; read(0, &c, 1);
       
 (DIR) Post #AVWW0HbTtMkhbsjvX6 by kirby@freespeechextremist.com
       2023-05-10T20:47:16.564777Z
       
       2 likes, 0 repeats
       
       @eris @p okay that's convinent
       
 (DIR) Post #AVWW3wlFKGRW7u3Qlk by p@freespeechextremist.com
       2023-05-10T20:47:56.926046Z
       
       2 likes, 1 repeats
       
       @kirby (Also getchar() returns an int rather than a char so be careful with using its output as a subscript.)
       
 (DIR) Post #AVWW5USnVSj8wUA3LE by kirby@freespeechextremist.com
       2023-05-10T20:48:13.665086Z
       
       1 likes, 0 repeats
       
       @p hurray!!!!
       
 (DIR) Post #AVWW7KKw82Ay77MNuq by kirby@freespeechextremist.com
       2023-05-10T20:48:33.579682Z
       
       2 likes, 0 repeats
       
       @p i don't care about its output here I just need to know when a key is pressed
       
 (DIR) Post #AVWWGZVN6PzPlPeJEW by p@freespeechextremist.com
       2023-05-10T20:50:13.810391Z
       
       2 likes, 0 repeats
       
       @kirby Okay, so you will want to probably do raw mode.  If you don't need the character, you can use select() to see if it's there.
       
 (DIR) Post #AVWWIAbUeii774H61I by kirby@freespeechextremist.com
       2023-05-10T20:50:31.157047Z
       
       1 likes, 0 repeats
       
       @p :D
       
 (DIR) Post #AVWWLaO1FjtnwfbKS0 by p@freespeechextremist.com
       2023-05-10T20:51:08.197339Z
       
       3 likes, 1 repeats
       
       @eris @kirby Yes, also this.  Also ungetc.
       
 (DIR) Post #AVWWc0DayiRGh8YNXM by apropos@freespeechextremist.com
       2023-05-10T20:54:06.211936Z
       
       3 likes, 1 repeats
       
       @kirby @p use tcsetattr for that: https://stackoverflow.com/questions/3276546/how-to-implement-getch-function-of-c-in-linuxor use ncurses.
       
 (DIR) Post #AVWWsJ4gdf1zoHA2Vs by eris@rdrama.cc
       2023-05-10T20:57:02.694280Z
       
       3 likes, 1 repeats
       
       @apropos @kirby @p Oh yeah, there are usually two levels of buffering because legacy, both the terminal and libc's FILE*
       
 (DIR) Post #AVWXhGO4OEYgFBWcnw by p@freespeechextremist.com
       2023-05-10T21:06:15.540297Z
       
       3 likes, 1 repeats
       
       @eris @apropos @kirby I don't know if it's a legacy thing.  The programs are still in separate memory spaces (thus the read is still a syscall), and there are lots of reasons to buffer it locally.
       
 (DIR) Post #AVWZ3H2ClPAIZoMDPk by kirby@freespeechextremist.com
       2023-05-10T21:21:26.531600Z
       
       1 likes, 0 repeats
       
       @apropos @p so tcsetaddr(stdin, TCSADRAIN, void)?
       
 (DIR) Post #AVWaWQIvThGXg6drX6 by kirby@freespeechextremist.com
       2023-05-10T21:37:54.917101Z
       
       1 likes, 0 repeats
       
       @apropos @p does not compile, hurrah. let me try another thing
       
 (DIR) Post #AVWabsrKjrcdghL75c by kirby@freespeechextremist.com
       2023-05-10T21:38:54.129012Z
       
       1 likes, 0 repeats
       
       @apropos @p :(image.png
       
 (DIR) Post #AVWamwtA66h5N1TGBE by p@freespeechextremist.com
       2023-05-10T21:40:54.112113Z
       
       1 likes, 1 repeats
       
       @kirby @apropos What did you do?
       
 (DIR) Post #AVWatbcRZlibQlpExc by kirby@freespeechextremist.com
       2023-05-10T21:42:06.289184Z
       
       1 likes, 0 repeats
       
       @p @apropos i tried to use last parameter as null. i had a feeling it wouldnt work
       
 (DIR) Post #AVWb1meQRXYPxjeTwG by p@freespeechextremist.com
       2023-05-10T21:43:34.976843Z
       
       2 likes, 1 repeats
       
       @kirby @apropos `man tcsetattr`
       
 (DIR) Post #AVWb4uDAn31gHOOSOW by kirby@freespeechextremist.com
       2023-05-10T21:44:08.829921Z
       
       1 likes, 0 repeats
       
       @p @apropos looking at the man page right now i dont know if its because im too new to c but i dont understand most of it
       
 (DIR) Post #AVWbOaAB2TX3tONI6S by p@freespeechextremist.com
       2023-05-10T21:47:42.193356Z
       
       2 likes, 1 repeats
       
       @kirby @apropos You just ask it for a struct from tcgetattr.  Probably easiest to just call cfmakeraw() on the result.struct termios attr;tcgetattr(0, &attr);cfmakeraw(&attr);
       
 (DIR) Post #AVWbtl5OThGEkK0GW0 by HWABAG@bae.st
       2023-05-10T21:53:19.176798Z
       
       0 likes, 0 repeats
       
       @kirby @apropos @p nerd.
       
 (DIR) Post #AVWc7lFKg8xfIVKSW0 by kirby@freespeechextremist.com
       2023-05-10T21:55:52.093564Z
       
       1 likes, 0 repeats
       
       @p @apropos im clueless.
       
 (DIR) Post #AVWcNklsDGpGSPAwK0 by p@freespeechextremist.com
       2023-05-10T21:58:45.506844Z
       
       1 likes, 1 repeats
       
       @kirby @apropos Nah, yer fine, this stuff takes a minute to get your head around.  First line allocates a termios named attr because these functions all want one, the second line populates it by asking tcgetattr() to fill in the attributes for FD 0 (stdin), the last line sets raw mode.
       
 (DIR) Post #AVWcaDXl41q1ATW58i by kirby@freespeechextremist.com
       2023-05-10T22:01:00.651183Z
       
       1 likes, 0 repeats
       
       @p @apropos it gets the last character from stdin and not when something new pops up in stdin?
       
 (DIR) Post #AVWcn57nfxEQp3VcTA by p@freespeechextremist.com
       2023-05-10T22:03:20.156350Z
       
       1 likes, 1 repeats
       
       @kirby @apropos That bit just sets the terminal to raw mode so that you can read stdin one byte at a time.  From there, you should read it with read().You usually don't wanna read stdin one byte at a time but if you want to do that, that is how you do that.
       
 (DIR) Post #AVWcrAJELHhe3lnouW by kirby@freespeechextremist.com
       2023-05-10T22:04:04.436848Z
       
       1 likes, 0 repeats
       
       @p @apropos crap this probably isnt what i wanna do
       
 (DIR) Post #AVWdEq31KEzqAbVbSC by kirby@freespeechextremist.com
       2023-05-10T22:08:21.137450Z
       
       1 likes, 0 repeats
       
       @p @apropos i'll just do this in a higher level language, i looked at another project doing the same thing as me theyre bringing in ncurses and shit for this
       
 (DIR) Post #AVWfOM7rd3VuAnRMHI by p@freespeechextremist.com
       2023-05-10T22:32:28.943398Z
       
       1 likes, 1 repeats
       
       @kirby @apropos What is it you're trying to do?
       
 (DIR) Post #AVWg1ITd85HU9MBpLs by kirby@freespeechextremist.com
       2023-05-10T22:39:31.205280Z
       
       1 likes, 0 repeats
       
       @p @apropos when a key is pressed just print a character from a string. That's all I want to do.
       
 (DIR) Post #AVWg3yuILXFEK7wSxc by kirby@freespeechextremist.com
       2023-05-10T22:40:00.310066Z
       
       1 likes, 0 repeats
       
       @p @apropos also I don't want the key pressed to print to stdout.
       
 (DIR) Post #AVWg5pZM2DpDwU1rmq by kirby@freespeechextremist.com
       2023-05-10T22:40:20.364996Z
       
       1 likes, 0 repeats
       
       @apropos @p explicitly just the character from the string
       
 (DIR) Post #AVWgDp1TwxReZ3zoqu by p@freespeechextremist.com
       2023-05-10T22:41:47.020798Z
       
       1 likes, 0 repeats
       
       @kirby @apropos Worst-case scenario, you can just dosystem("/bin/stty -raw");
       
 (DIR) Post #AVWgLwDb570fCIX64O by kirby@freespeechextremist.com
       2023-05-10T22:43:15.025567Z
       
       1 likes, 0 repeats
       
       @p @apropos what does that do?
       
 (DIR) Post #AVWgz9IcNeU33qZvu4 by p@freespeechextremist.com
       2023-05-10T22:50:20.214290Z
       
       2 likes, 1 repeats
       
       @kirby @apropos Just calls the program that does what you're doing.  You should probably do "/bin/stty -raw -echo", actually.  It's better to get the cfmakeraw() call to work but this will do in a pinch.You can see what it's actually doing under the hood by doing `strace -vv stty -raw -echo` in the shell.  It just calls ioctl() with some special values.