Questions tagged [fputs]

Anything related to C or C++ standard library functions `fputs` (C) or `std::fputs` (C++). These functions are used to write a null-terminated string to an output stream.

Anything related to C or C++ standard library functions fputs (defined in <stdio.h> C standard header) or std::fputs (defined in <cstdio> C++ standard header). These functions are used to write a null-terminated string to an output stream.

See CPPreference.com:

123 questions
0
votes
4 answers

File name string errors

I'm having a little trouble with the code below and I can not for the life of me figure out what went wrong and why it is displaying what it does, any help or assistance would be most appreciated. It is supposed to allow 5 lines of text to be…
The10thDoctor
  • 125
  • 1
  • 13
0
votes
2 answers

PHP String Comparison not working as expected

I have the following snippet of code that I am trying to use to read a file that can have some lines repeated two or more times. The goal of this script is to only write unique lines (no duplicates) but for some reason it appears that it is not…
pogeybait
  • 3,065
  • 2
  • 21
  • 23
0
votes
1 answer

Turning form input into text in a file using php

I have a HTML form with the following:

Karl
  • 517
  • 7
  • 18
0
votes
3 answers

PHP fputs not working

I have the following code to create a LOG file. It is implemented inside "download.php", a script to force download which I call from download links such as: Filename to download Download links are at any…
qalbiol
  • 475
  • 7
  • 21
0
votes
2 answers

Merge - Compare - Output (C)

I am creating a program that takes two .txt (data1.txt, data2.txt) files that contain integers that are stored in ascending order and merging them in a output.txt (data3.txt) in ascending order. I am using the fgets function to read each int from…
boutrosc
  • 317
  • 1
  • 5
  • 11
-1
votes
1 answer

fputs causing error corrupted size vs prev size

I am working on a project in C language and my code keeps crashing of fputs command. This is the code: void entry_file_creation(int lc, int error_flag_line, char *source_file_name) { int j = 0; FILE *entry_ptr = malloc(sizeof(FILE*)); if…
-1
votes
1 answer

Can I use fputs and fgets in file opened in binary

The data in file is random and both alphabet and numbers. /**** Program to APPEND one file after another file ****/ #include #include int main() { FILE *fp, *fc; char data[200]; fp = fopen("students.DAT", "ab"); …
-1
votes
2 answers

Confusion about fputs()

#include int main() { char str[100]; printf("Enter a string: "); fgets(str, sizeof(str), stdin); fputs("Liverpool", stdout); fputs("Manchester", stdout); return 0; } OUTPUT Enter a string : punch LiverpoolManchester But,…
Got_R3kt
  • 1
  • 3
-1
votes
1 answer

C Programming - type in the program that copies a file using line-at-a-time I/O (fgets and fputs) but use a MAXLINE of 4

I apologize in advance because I just started learning C. This is my code so far. int main () { char buf [4]; // open the file FILE *fp = fopen("readme","r"); // Return if could not open file if (fp == NULL) return 0; while(fgets(buf,4,fp) !=…
-1
votes
1 answer

fputs doesn't write before 403 header is triggered

I have a function forbid() that is supposed to write to a log file that access was denied, along with a reason for the denial. For some reason, it's not writing to the logfile. // function to forbid access function forbid($reason) { // explain…
JacobTheDev
  • 17,318
  • 25
  • 95
  • 158
-1
votes
2 answers

writing and reading within a fork - C

The exercise is simple. The father process lets me write my name and surname in a file. The son process waits 5 seconds, then reads and displays it. I can't use the #wait() function. #include #include #include #include…
Luca Datti
  • 1
  • 1
  • 2
-1
votes
1 answer

Trying to write to a file

I am trying to open and then write to a .dat file. The file is just a simple series of numbers, but i would like to add to it. Right now the fputs isn't working for me. I was wondering if I am using the right function to do the job. Right now it…
screw you
  • 141
  • 1
  • 10
-1
votes
1 answer

Opera 11.50 file write on page reload issue and cookies, php session errors

I have a problem which I can't understand. The problem occurs only on Opera 11.50 browser. I have simply write to file function. fopen, LOCK_EX, fputs, LOCK_UN, fclose. When I normally open pages, everything is ok. But when I reload page, then…
-1
votes
2 answers

C Get a string from a file

I want to get 2 variable strings of fixed length (10chars and 32chars) from a file and save them as variables to pass off later in my program and write them to a new file. I can write the data to a new file from user input but I can't seem to…
jhayton
  • 301
  • 1
  • 10
-2
votes
1 answer

php - ob_start / fputs suddenly doesn't work anymore, is there anything that can stop it?

My code: function log_this($to_log, $prepend = null){ ob_start(); $fn = '../info.log'; $fp = fopen($fn, 'a'); fputs($fp, "\r\rnew log -------- \r\r"); if(isset($prepend)) fputs($fp, $prepend . ":\r\r"); …
Luca Reghellin
  • 7,426
  • 12
  • 73
  • 118
1 2 3
8
9