Skip to main content
Stack Overflow
  1. About
  2. For Teams
Filter by
Sorted by
Tagged with
3 votes
1 answer
135 views

I am writing a simple shell in C on Linux. My goal is to handle the Ctrl+D (EOF) signal such that if the user types a command (e.g., ls) and presses Ctrl+D, the shell exits immediately without running ...
-3 votes
1 answer
197 views

I am following the Bro Code course of C and there is something I am not fully understanding. This might be a basic question, but I cannot figure out what is going on behind the function fgets. When ...
-3 votes
2 answers
208 views

#include <stdio.h> #include <string.h> int main(){ char filename[32], userdata[4096]; printf("type the filename bro: "); fgets(filename, 32, stdin); printf(&...
Python_15's user avatar
0 votes
1 answer
68 views

typedef struct { char name[20]; }NAME_1; static void ex6() { NAME_1 name; fflush(stdin);// clean buffr input printf("Name: "); fgets(name.name, 20 , stdin); printf(&...
Guerra's user avatar
  • 11
0 votes
3 answers
152 views

#include <stdio.h> #include <stdlib.h> #include <string.h> #define MAXSIZE 10 int main(int argc, char *argv[]){ char input[MAXSIZE], c, *input_ptr; input_tag: printf("...
Bittu970's user avatar
  • 107
1 vote
1 answer
78 views

I am new to C programming, and right now doing my first assignment in a C course. I have noticed an unusual behavior when using a string in my code. I am currently writing a simple string encoder, our ...
0 votes
1 answer
98 views

Please see the following piece of code in C printf ("\nEnter the lines (terminate each line with ENTER...\n\n"); for (i = 0; i < lines; i++) scanf (" %[^\n]", s[i]); I have ...
1 vote
2 answers
136 views

To detect it, I've seen the following if condition: #include <stdio.h> #include <string.h> #include <stdlib.h> int main(){ char line[5]; while(fgets(line, 5, stdin)){ int ...
Isidro Arias's user avatar
0 votes
2 answers
211 views

I am learning C and I am looking at some tutorials and I am now learning about while. In the video there was example of asking "what is your name?" and while is used there as a tool that ...
4 votes
2 answers
238 views

This is fgets()'s official prototype: char *fgets(char *str, int n, FILE *stream); Why specify the size (n) ? Is it to prevent buffer overflow of some sort? Or is it just a design flaw? I would think ...
2 votes
3 answers
218 views

Just so I can confirm if what I think is going on is really going on. The following code prints out 25 when I give it the (26 letter) alphabet as an input, is it because fgets always automatically ...
0 votes
0 answers
42 views

I have to make an array of structure for cricketers presenting their name, age etc. and take input of each value from user . I am trying to get value of name from the user but my code editor keeps on ...
0 votes
2 answers
75 views

I am writing a C++ program for an embedded Linux application for a custom device. Very often, I run Linux terminal commands via popen and pclose. If I need to only check whether the command was ...
-1 votes
2 answers
109 views

I have been sitting on this simple fundamental mistake for a while. How do we avoid strings in the stdin, that are bigger than a defined sizeof(sring). Here sizeof(stdin_passed) > sizeof(word_new)....
plantpot's user avatar
1 vote
2 answers
162 views

Is it correct that in C programming when we pass the parameters pointer_to_string, sizeof_string and the stream for the fgets() function, we do not have to write back the return of the function to the ...
plantpot's user avatar

15 30 50 per page
1
2 3 4 5
...
140

AltStyle によって変換されたページ (->オリジナル) /