128 questions
- Bountied 0
- Unanswered
- Frequent
- Score
- Trending
- Week
- Month
- Unanswered (my tags)
3
votes
0
answers
131
views
Why does setlocale cause fputs to produce garbled output in the Windows console?
My Windows system ANSI code page is GBK, and I am working on a Windows console program.
// SetConsoleOutputCP(65001); // Neither code page 936 nor 65001 affects the result.
char utf8[] = { 0xE4, 0xB8, ...
3
votes
0
answers
62
views
Why is stdout behaving unbuffered by default? (mingw-w64 gcc) [duplicate]
I've been doing some exercises with printing to streams in C.
Today I've been a bit confused: as I understand in most implementations of the C standard library, the default behaviour of stdout is ...
0
votes
3
answers
134
views
What is the right way of printing non formatted string not ending in new line?
printf("foo: ");
vs
fputs("foo: ", stdout);
As mentioned in the title, the string is not formatted and does not end in a new line (so no puts). I am not sure about overheads and ...
0
votes
3
answers
135
views
how to make fputs function prompt wrong input and ask user to input again...program stopping instead of request for new input
i'm doing calculation for result. user will input 3 type of result that is pass, fail & invalid. I need to have 1 more checking that is when user input result other than integer value it will be ...
0
votes
1
answer
123
views
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;
...
1
vote
0
answers
46
views
tmpfile_s() reads as empty even after fputs() [duplicate]
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 ...
0
votes
2
answers
169
views
PHP processes a CSV file into 19 Smaller CSV's very slow
I have created this php script which takes a very long time to filter the CSV file into 19 smaller ones. The link for the CSV's is within this google drive line
https://drive.google.com/drive/folders/...
0
votes
0
answers
38
views
I have got struck in a problem where I have the task to update the old line with a new line in a .txt file using C
I have opened the file in "r+" mode and tried to use fputs to replace old_line (line) with new_line (updated_line)
char updated_line[] = "Hello This was ABCD";
fseek(fp, -(strlen(...
1
vote
1
answer
215
views
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); ...
0
votes
3
answers
132
views
How does Visual Studio Code handle the fputs statement for File I/O in "r+" mode?
I have written a code
#include <stdio.h>
#include <stdlib.h>
int main()
{
FILE *fp;
fp=fopen("lets.txt","r+");
if(fp==NULL)
{
printf("ERROR&...
0
votes
1
answer
84
views
Why when read and write performed back to back in file opened in rb+ mode behaves not as expected in c language
I opened a file in rb+ mode successfuly
Wrote two strings using two fputs.
File ptr moved to 3 byte from file beginning using fseek.
Read four characters successfuly using fgets.
Now when I tried to ...
0
votes
0
answers
57
views
How to copy my file on disk after receive from a socket in C?
I'm programming a server with C and I send file with my client. I receive the file with my server and i want to write it on disk.
I print it to be sure i had it.
Everything are ok but when i write on ...
0
votes
3
answers
779
views
Print char array with fputs or other - C
The first array prints all right.
test[] =
However, when the array is like in the second example, test[][] ={"...","..."};
I get an incompatible warning.
In the second example with ...
-1
votes
1
answer
428
views
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 <stdio.h>
#include <fcntl.h>
int main()
{
FILE *fp, *fc;
...
0
votes
1
answer
63
views
Downloading file, changing extension and merging into 1 file
Trying to download files via the URL, rename from the .ADM extension to .txt
then put contents of each file into a single txt file
However its saying the fputs param 2 is a resource
The $logfile['name'...