fgets Questions
3
Solved
I've written this minishell but I'm not sure I'm making a correct control of the errors. I know fgets can return feof and ferror (http://www.manpagez.com/man/3/fgets/)
but I don't know how to...
1
Solved
I have just recently started working with I/O in C. Here is my question - I have a file, from which I read my input. Then I use fgets() to get strings in a buffer which I utilise in some way. Now, ...
1
Solved
I understand that fgets reads until EOF or a newline.
I wrote a sample code to read lines from a file and I observed that the fgets gets executed more than the desired number of times. It is a ver...
7
Solved
Specifically, the code sample here works great, but only when the string is stored in a file.
Sometimes I need it to process a generated string (stored in a string variable), but I'm having troub...
3
I have a simple question about using fgets() with char* string.
....
char *temp;
FILE fp=fopen("test.txt", "r");
fgets(temp, 500, fp);
printf("%s", temp);
....
This code didn't work well.
But ...
6
I want to know what is the difference between fgets() and scanf(). I am using C as my platform.
3
Solved
I am using fscanf to read in the date and then fgets to read the note.
However after the first iteration, fscanf returns a value of -1.
I used GDB to debug the program step by step. It works fine ...
4
I'm trying to read user input and store it as a string including the whitespace. I did a search for a solution and was pointed to fgets() or scanf(%[^\n], str). But both these solutions give me an ...
1
Solved
I try to use file_get_contents form PHP but it's not working.
There is my code :
$filename = "/opt/gemel/test.txt";
if($filecontent = file_get_contents($filename)){
$nom = fgets(STDIN);
fil...
Headreach asked 12/7, 2013 at 12:32
6
Solved
I'm trying to open a file, and read from it.. but I'm having some issues.
FILE *libFile = fopen("/Users/pineapple/Desktop/finalproj/test242.txt","r");
char wah[200];
fgets(wah, 200, libFile);
prin...
Claudclauddetta asked 17/11, 2010 at 19:55
2
I'm writing a function that perform some authentications actions. I have a file with all the user_id:password:flag couples structured like this:
Users.txt
user_123:a1b2:0 user_124:a2b1:1 user_125...
1
Solved
I was wondering if there is any way to ignore whitespace with either the fscanf or fgets function. My text file has two chars on each line that may or may not be separated by a space. I need to rea...
1
Solved
I have been following a tutorial on how to make my own shell but I have been stuck for a couple days now.
Two things:
When this code is compiled and ran, it will randomly have segmentation fault...
Schade asked 3/10, 2012 at 20:22
6
Solved
4
Solved
For unknown reason, result of running my C program is quite unexpected. I think that it has to be some kind of a beginner mistake, however I can't find out really, where is it.
#include <...
2
Solved
I have this following scenario.
I create a pipe.
Forked a child process.
Child closes read end of the pipe explicitly and writes into the write end of the pipe and exits without closing anythi...
Janice asked 6/8, 2012 at 10:24
4
Possible Duplicate:
Why does printf not flush after the call unless a newline is in the format string? (in C)
I am getting a problem using printf and fgets as in my code printf is wri...
4
Solved
i have to write a program in C to read a file containing several line of text, each line contains two variables: a number (%f) and a string:
EX: file.txt
============
24.0 Torino
26.0 Milano
27.2 ...
2
Solved
Here is the code that I am using:
if (!($fp = fsockopen('ssl://imap.gmail.com', '993', $errno, $errstr, 15)))
echo "Could not connect to host";
$server_response = fread($fp, 256);
echo $server_re...
2
I was wondering if anyone out there knew how this could be done in PHP. I am running a script that involves opening a file, taking the first 1000 lines, doing some stuff with those lines, then the ...
Toiletry asked 26/3, 2012 at 18:14
2
Solved
I am reading from file of format
1 32 43 23
32 43
123 43 54 243
123 2222
2
Here is my code snippet.
string[100];
while(!feof(fp))
fgets(string,100,fp)
Now, when I put every string, in the l...
4
Solved
I have a question concerning fgets and fscanf in C. What exactly is the difference between these two? For example:
char str[10];
while(fgets(str,10,ptr))
{
counter++;
...
and the second example:...
2
Solved
If I type å in CMD, fgets stop waiting for more input and the loop runs until I press ctrl-c. If I type a "normal" characters like a-z0-9!?() it works as expected.
I run the code in CMD under Wind...
Caucasus asked 30/11, 2011 at 18:58
5
Solved
So, I'm trying to find a way to fgets() a specific line in a text file in C, to copy the contents of the line into a more permanent buffer:
Essentially, I was wondering if there was a way to do th...
Coenosarc asked 17/11, 2011 at 22:14
2
Solved
Why does this particular piece of code return false on the strstr() if I input "test"?
char input[100];
int main()
{
fgets(input, 100, stdin);
printf("%s", input);
if(strstr("test message", i...
© 2022 - 2024 — McMap. All rights reserved.