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
2 answers

fgets() works wrong in for loop

I am trying to use fgets and fputs to copy-paste a file. I wrote in two ways, one in for loop, the other in while loop. While loop works perfectly, but for loop acts weird. I tried to debug and wrote this: FILE *infile = fopen("infile", "r"); FILE…
kowalski
  • 11
  • 4
0
votes
1 answer

fputs() producing wrong result

My code is producing incorrect result. I don't know why. When I give the length as 5 and enter the string as "vasanth", this should produce "vasan" as output. But it gives output as "vasa". #include #include int main(){ int…
0
votes
0 answers

Create a `FILE` from an internal function (not a file)?

POSIX/C defines a number of nice functions to deal with file objects, like fputs and fprintf. /* `FILE*` rather than `SomeType*` wanted? */ void f(const char *text) { SomeType* printer_object = \ …
A T
  • 13,008
  • 21
  • 97
  • 158
0
votes
2 answers

DIfferent behaviour on Edge/Chrome and Firefox on save filename

I work on a project and i am facing a strange behaviour between edge/chrome and firefox. I'm trying to save a file with filename like file_[ip address]-[username].txt. Sending data from html page through ajax .. ...
php_freak
  • 16
  • 2
0
votes
0 answers

Smali file is corrupted after writing with fputs()

Goal : i want to inject a one line code in smali My current approach I am reading smali file with getline() and writing whole content to a new file with some changes. Here is code while(getline(&line,&line_size,smaliFile) != -1) { if (FLAG)…
Golu
  • 350
  • 2
  • 14
0
votes
3 answers

How to read from file and write another in c

I have a input file like this: This is 1nd Line. This is 2nd Line. This 3rd Line. And I need to output files like OddLines.txt: This is 1nd Line. This 3rd Line. EvenLines.txt: This is 2nd Line. Here is my code. And not working as I wanted. …
user13561105
0
votes
0 answers

Write a line to a file line from a struct with a handful of members

typedef struct { char name[64]; int balance; int gain; } Player; "%s\t%d\t%d\n", p.name, p.balance, p.gain ; I'm trying to input this into my file and I'm wondering if there is any way that I could make that into one string so it will work with…
0
votes
1 answer

php echo a javascript variable to file.txt

I've this code that works fine to get the user Timezone and echo in php. There's also an alert message before.