Skip to main content
1 vote
2 answers
139 views

I was trying to make a program that erases spaces and comments from a text file: #include <stdio.h> #include <stdlib.h> #include <stdbool.h> #define SIZE 10 static inline bool ...
Aperture Science's user avatar
3 votes
1 answer
152 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 ...
Billie Jean's user avatar
-3 votes
1 answer
208 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 ...
VICTOR HUGO CORREA - MARQUEZ's user avatar
-3 votes
2 answers
209 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
153 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 ...
Din Yair Sadot's user avatar
0 votes
1 answer
99 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 ...
Vinayak Deshmukh's user avatar
1 vote
2 answers
137 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
215 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 ...
Ján Franko's user avatar
4 votes
2 answers
246 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 ...
Cccc's user avatar
  • 93
2 votes
3 answers
219 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 ...
Guilherme Cintra's user avatar
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 ...
Harshit Gupta 's user avatar
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 ...
ysba's user avatar
  • 21
-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

15 30 50 per page
1
2 3 4 5
140