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

fwrite() expects parameter 1 to be resource, string given in c://

I am using latest version of php.. and i stuck on this error Warning: fwrite() expects parameter 1 to be resource, string given in c:\ this error shows me 6 times Warning: fclose() expects parameter 1 to be resource, string given in // this error…
Phoenix
  • 467
  • 1
  • 11
  • 23
1
vote
1 answer

Proper use of fprintf

Is this ever acceptable? fprintf(fp,"Just a string"); or fprintf(fp,stringvariable); versus fprintf(fp,"%s","Just a string"); It seems confusing to me as the string variable (or constant) is used as the formatting versus the output itself. It…
Jiminion
  • 5,080
  • 1
  • 31
  • 54
1
vote
1 answer

File corruption C with fputs and SED

I have a 'queue' (it's not quite FIFO) which is backed by files on the disk once it has run out of its preallocated memory. The built code is being executed on an ARM SBC. The problem I'm having is that after a while the SD card (or a particular…
Cooper
  • 35
  • 7
1
vote
1 answer

When writing to a file, fputs() does not change line

I'm currently trying to create a database in C, using a .txt document as the place to store all the data. But I can't get fputs() to shift line, so everything that my program writes in this .txt document is only on one line. int main(void){ …
Asger Weirsøe
  • 350
  • 1
  • 11
1
vote
1 answer

PHP fputs "waits" until the end of the script

Currently I am trying to develop a PHP script used as a publicly available part of a client/server application. The php script should be used to authenticate users with a one-time token. The other part of the application is a java program, which…
Michael G.
  • 78
  • 5
1
vote
1 answer

Strip default quotes on some values in fputs

I need to export some values to an csv using php and I need to strip the first two values in my array of its default quotes (even if it has a space) and keep the default quotes on the last value. So the result I am looking for in the exported csv…
Linda
  • 45
  • 4
1
vote
2 answers

Writing a file using c program in the format of table

I want to write a file in the format of table using c program. I am using fputs to write the file. My file looks like : [sl] [Name] [School] [add] 1 ABC DEF Dav India 2 XYZ LLL USA But, I want output file to look like : [sl] …
Pratik Kumar
  • 67
  • 1
  • 7
1
vote
0 answers

Getting Resource from fsockopen behing proxy

I have an existing code which is : $Socket = fsockopen(HOST, PORT); where $Socket returned here is a resource. However, i need to get it behind a proxy server with Authentication. I am sure it could be done via public static function…
Guns
  • 2,678
  • 2
  • 23
  • 51
1
vote
0 answers

Next file is created before completion of the First file in PHP?

in Php i have written a code like below //Example Code foreach($arrayitem as $arr) //$arrayitem is having some array data { $fp=fopen($arr.'.xls','w'); for(condition) { //here i'm getting full content of an webpage(huge data) and some regexp…
ɹɐqʞɐ zoɹǝɟ
  • 4,342
  • 3
  • 22
  • 35
1
vote
2 answers

fputs for writing an EBCDIC character array

If I have a character array that is in EBCDIC format and I want to save that array to a file. I'm thinking of using fputs to output the character array without first converting it to another format. Question) Is the use of fputs legal for writing…
Chris Snow
  • 23,813
  • 35
  • 144
  • 309
1
vote
4 answers

syntax error near unexpected token '(' in C

I'm getting a confusing error message. I'm running MinGW on Windows XP 32-bit. When I attempt to compile the following code, I get an error message "./hello.c: line 4: Syntax error near unexpected token '('". Line 4 is at int main(...), I can't…
Josh
  • 11
  • 1
  • 1
  • 5
1
vote
1 answer

fputs vs. fprintf and double

I need to put out a double value into an file. So for all my other string i have to put out i use fputs because i think and timed it that fputs is faster then fprintf. But if i want to put out the double value i can't do this with fputs so i tried…
bladepit
  • 853
  • 5
  • 14
  • 29
1
vote
2 answers

C phonebook program: Reposition cursor in text file to start of previous line

writing a C program which opens a text file called phoneList.txt and searches for contacts (firstname, lastname, phonenumber), and updates an existing contact's phone number. My issue is in the update phone number program. When I use fgets to find…
user1730099
  • 81
  • 1
  • 3
  • 6
1
vote
2 answers

How do you retrieve the first n lines of a file? (php)

$fileName = file ("gstbook.txt"); $rows = count ($fileName); // $Char is the string that will be added to the file. if ($Char != '') { $Char = str_replace ("\n","
",$Char); $Char = strip_tags ($Char, '
'); $newRow = '' .…
WaxyChicken
  • 139
  • 2
  • 10
1
vote
3 answers

Simply fputs() example returns EOF

This simple program, gives me troubles in fgets(), returning EOF, that is an error value for fgets() I don't understand where is the problem #include #include #include FILE* openFile(const char* path) { FILE*…
Germano Massullo
  • 2,572
  • 11
  • 40
  • 55
1 2
3
8 9