Linked Questions

4 votes
2 answers
2k views

I'm trying to simulate a command line shell. The user inputs a shell command they want to input, e.g. /bin/pwd and the code is meant to execute it. The buffer is set to read a fixed number of chars (...
doctopus's user avatar
  • 5,757
0 votes
0 answers
80 views

fgets() and gets() works properly for the first time. When I use this function for the second time then I am not asked for the input. #include<stdio.h> int main(){ char name[10]; printf(&...
user3243634's user avatar
0 votes
0 answers
40 views

I'm reading the terminal input of characters with the getchar() function and from it I have to store the duration and the description of a task. What I'm trying to figure is how to discard the entire ...
vugod's user avatar
  • 1
13 votes
5 answers
53k views

I am trying to read a number character by character, but I don't know if the stdin buffer is empty or not. My first solution was to look for '\n' character in the stdin buffer, but this isn't any good ...
Tandura's user avatar
  • 908
1 vote
4 answers
711 views

I am a newbie in C. Consider my following code: #include <stdio.h> #include <string.h> int main() { char strs[5][6]; char temporary[5]=""; for(int i=0;i<5;i++) ...
Kabir's user avatar
  • 59
2 votes
1 answer
2k views

I'm reading/practicing with this book about C language: "C Programming - A Modern Approach 2" and I stumbled upon this piece of code whose explanation is odd to me: Since scanf doesn't normally skip ...
dotthor's user avatar
  • 68
2 votes
1 answer
704 views

I have a problem where if a user enters an input greater than the max number of characters such as "abcdefg" when the max is 5, the fgets() that is within a loop runs twice and instead of "abcd" it ...
Jae Yang's user avatar
  • 559
0 votes
2 answers
1k views

I was reading up on Python Networking using sockets and found the code below at the end. I have the server file which works fine and starts the server on port 9009. # chat_client.py import sys, ...
Inkblot's user avatar
  • 748
0 votes
1 answer
750 views

I'm in an operating systems course and doing assignments with C on Linux. In one of the assignments I was supposed to redirect and output to a file, but for some reason, I keep getting the output in ...
Lidor Cohen's user avatar
2 votes
2 answers
204 views

I am building a quiz project on C. My question is, can I use a command or use something to make the user decide if he wants to keep answering questions or not. For example here is a part of my code. ...
pronoobgr's user avatar
1 vote
3 answers
366 views

When I added the main while loop, the program just always runs, and runs through again and with a message telling me there is invalid data (from my first input validation). Can anyone show me how to ...
Mohtsu's user avatar
  • 31
2 votes
2 answers
261 views

#include <stdio.h> int main(){ char ch; while((ch=getchar())!=EOF){ putchar(ch); } char ch2 = 'A'; printf("ch2=======>%c\n",ch2); ch2 = getchar(); printf("...
Rick's user avatar
  • 7,664