Questions tagged [cstdio]

A C++ wrapper for C standard IO header stdio.h.

55 questions
0
votes
1 answer

std::ios_base::sync_with_stdio(false), advantages, disadvantages?

What is the difference between std::ios_base::sync_with_stdio( false ); Vs std::cout.sync_with_stdio( false ); and std::cin.sync_with_stdio( false );? Which one should I use supposing my code does not use any of the C streams from and only…
digito_evo
  • 3,216
  • 2
  • 14
  • 42
0
votes
1 answer

How do I use std::rename with variables?

In my program, I store data in different text files. The data belongs to an object, which I call rockets. For example, the rocket Saturn 5 has a text file labeled "Saturn5R.txt". I want an option to rename the rocket, and so I will need to rename…
0
votes
0 answers

Scanf does not work with multiple inputs on different lines

when I run this program it compiles but the second scanf statement just prints and doesn't actually get any variable. However, if I remove the first scan, the program works. #include struct file_struct { FILE *fp; }; int main(int…
Ankit
  • 1
  • 2
0
votes
0 answers

Will disabling the synchronization effect time if there is no printf() in C++?

I read the answers on Significance of ios_base::sync_with_stdio(false); cin.tie(NULL); which basically states significance of ios_base::sync_with_stdio(false); which matters when we mix the usage of cout and printf() in C++ and helps to speeds up…
simplekind
  • 39
  • 4
0
votes
1 answer

how to read and write non-fixed-length structs to biniary file c++

I have vector of structs: typedef struct { uint64_t id = 0; std::string name; std::vector data; } entry; That I want to write to file: FILE *testFile = nullptr; testFile = fopen("test.b", "wb"); However the normal method for…
Mutaru
  • 65
  • 1
  • 2
  • 10
0
votes
0 answers

getting cstdio errors despite it not being included? (Visual Studio)

I'm trying to compile a C program in Visual Studio 2019, I have 'Compile As' set to 'Compile as C Code (/TC)' and cstdio is not included anywhere in my project, yet it still gives me cstdio errors C:\Program Files (x86)\Microsoft Visual…
user12586940
0
votes
0 answers

Proper way to use standard c++ printf() function as interface to custom library to print to a character display

First, some background. I have acquired a few of these Avago HCMS-29xx LED displays. there is an Arduino library for controlling them, but I want to use a raspberry pi. So I have forked the original library's GitHub and started porting. The library…
u6bkep
  • 1
  • 1
0
votes
1 answer

Unable to use double variable in C++ using cstdio

C++ code for double using cstdio header. #include using namespace std; int main() { double f; scanf("%lf",&f); printf("%lf",f); return 0; } This code always…
GIRISH kuniyal
  • 740
  • 1
  • 5
  • 14
0
votes
2 answers

I am not able to understand why output is coming 10 in this for loop

can anybody clear my doubt .. why this program is giving 10 as output. can you please explain the mechanism .. for loop is also having ; before the statements also #include using namespace std; int main() { int i ; for ( i =0 ;…
0
votes
0 answers

Header for CStdioFile , if I am already including windows.h

Which header shall i use for CStdioFile? The relevant doc is here when I try including afx.h , i get following error( window.h is included before afx.h because of some other function): Error 1 error C1189: #error : WINDOWS.H already included. …
alabama1
  • 11
  • 4
0
votes
2 answers

Multiple inputs in C

I'm trying to create a function that gets multiple inputs for resistances value. In my main function the program asks the user to ask how many resistors are needed. The number of resistors needed by the user will become the number of times the…
0
votes
0 answers

Error while trying to store .ppm image data

While trying to store the image data for a .ppm file I trip an error that says: Unhandled exception at 0x01071712 in Map.exe: 0xC0000005: Access violation writing location 0x0bf13746. I assume this means its writing to some part of memory that…
0
votes
2 answers

Not understanding the C format specifiers when using fscanf()

So I am reading a text file in this format: ABC 51.555 31.555 DEF 23.445 45.345 I am trying to use fscanf() to parse the data, because this file could grow or shrink it needs to be dynamic in the way it loads hence why i used malloc and i also want…
Definity
  • 691
  • 2
  • 11
  • 31
0
votes
1 answer

No console output in simple c++ program

I noticed a weird behaviour of some of my programs in c++ and when I was trying to figure out what coused it, I found out, that something wrong is going on with my console outputs. I used iostream and cstdio functions with the same behaviour. When I…
fifco
  • 11
  • 6
0
votes
1 answer

Clarification on fsetpos, C++

I am a little confused with function fsetpos in the stdio.h library. I want to be to write to different indexes (i.e do not want to write to a file contiguously) in a file. I was considering using fsetpos however the documentation states.. The…
Rstack
  • 45
  • 1
  • 10