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
1
vote
1 answer

File writing conflicts : file_get_contents() & fputs()

Im at a bit of a loss, i have 2 scripts 1 which pulls email attachments from a mailbox and a second one which then parses the attachments and adds them to the DB. This works ok most of the time, but is throwing up a few issues every now an again.…
cosmicsafari
  • 3,949
  • 11
  • 37
  • 56
1
vote
5 answers

c : gets() and fputs() are dangerous functions?

In the computer lab at school we wrote a program using fputs and the compiler returned an error gets is a dangerous function to use and a similar error for fputs but at home when i type in this bit of code: #include main() { FILE *fp; …
tarashish
  • 1,945
  • 21
  • 32
1
vote
2 answers

fputs(): supplied argument is not a valid stream resource

Hi I'm trying to add private proxy support to a PHP class that is using fsockopen rather than cURL and I'm a bit lost with it! I have the following code which is producing an error warning for each of the fputs lines: fputs(): supplied argument is…
Luke Bream
  • 855
  • 2
  • 10
  • 15
1
vote
1 answer

How to read multiple lines of input from user using fgets and write it into a file using fputs in C?

I wanted to read input from user (multiple lines) and write it into a file using fputs(). Here is my code #include #include int main() { FILE *fp; char s[25]; fp=fopen("myname","w"); if(fp==NULL) { perror("Error opening…
Dinesh
  • 16,014
  • 23
  • 80
  • 122
1
vote
0 answers

tmpfile_s() reads as empty even after fputs()

Here is a minimal example that does not do what I expected after the counsel of the user in comments to original question. You can see the issue is not about fflush() because it is called after the fputs(): #include int main() { …
1
vote
1 answer

Why my fputs doesn't work when the file already contains anything?

I try to add a new line to the already existing file, which already consists some text. I found out that when the file contains something, the program stops working after fputs(stringToAdd, myFile); in function void Save(struct SEED arrayToSave[],…
1
vote
1 answer

Creating and writing a file in WordPress using PHP

I would like to create a file to cache my lookups (coordinates and so on). I don't know why but I cannot create and write to it within WordPress. I am using this code for a try:
Marina Santini
  • 99
  • 1
  • 3
  • 12
1
vote
1 answer

fputs slowly writing to disk

I have a php script which writes csv files to disk, this is the function: function fputcsv_content($fp, $array, $delimiter=",", $eol="\n") { $line = ""; foreach($array as $value) { $value = trim($value); $value =…
Matias
  • 539
  • 5
  • 28
1
vote
3 answers

php file writing problem

I have a script which constanly append strings into a file. For example (this is a test script): $i = 1; $file = 'wikipedia/test.txt'; $text = 'the quick brown fox jumps over the lazy dog'; while($i!=0) { file_put_contents($file, $text,…
ralpu
  • 193
  • 3
  • 15
1
vote
1 answer

Why does C puts appends a newline while fputs doesn't?

The C standard provides two functions, puts and fputs, with puts(s) behaving as fputs(s, stdout) except that it additionally appends a newline: The puts() function shall write the string pointed to by s, followed by a , to the standard…
vitaut
  • 49,672
  • 25
  • 199
  • 336
1
vote
2 answers

How to get access of file pointer from one function to another?

I want to store the data in location but whenever I run the code it give me message that the fp is undeclared. I want fp to be working in another function. How to do this? #include #include #define MAX 15 int new_acc(char…
1
vote
2 answers

'Control reaches end of non-void function' in C

I am trying to read the user's input. When I compile the program I get the message, 'control reaches end of non-void function [-Wreturn-type] }'. char *read_line(char *buf, size_t sz) { while(fgets(buf, sz, stdin)) { fputs(buf, stdout); …
Jake Jackson
  • 1,055
  • 1
  • 12
  • 34
1
vote
1 answer

fwrite , fputs byte safe

I want to send data via POST to a php page, I need to store the bytes exactly as they are but I wasn't able to do it. When I send 138 bytes, fputs and fwrite returns 133. $fh = fopen($myFile, 'ab') or die("can't open file"); echo fputs($fh,…
Tareq Ibrahim
  • 365
  • 5
  • 18
1
vote
1 answer

Why do we have to dereference stdout here?

I am trying to call fputs(str, stdout); from assembly. Why should I push dword [stdout] instead of just push stdout? Since in C we don't do fputs(str, *stdout), why do we need to dereference stdout in assembly? Full code: extern fputs extern…
itsfarseen
  • 1,109
  • 10
  • 25
1
vote
4 answers

Should I use fputs or putchar?

Here is my following program. I don't want a new line, which is why I used fputs() instead of puts() char words[5][6] = {"One", "Two", "Three", "Four", "Five"}; for (i = 0; i <= 4; i++) fputs(words[i], stdout); I was wondering if this line of…
1
2
3
8 9