A C++ wrapper for C standard IO header stdio.h.
Questions tagged [cstdio]
55 questions
0
votes
2 answers
sscanf string format specifiers not works for '\t'
#include
#include
#include
char *tokenstring = "first,25.5,second,15";
int result, i;
double fp;
char o[10], f[10], s[10], t[10];
void main()
{
result = sscanf(tokenstring, "%[^','],%[^','],%[^','],%s", o, s, t, f);
…

Nick Dong
- 3,638
- 8
- 47
- 84
0
votes
2 answers
Flush Input Buffer C
Note: fflush(stdin) did not work.
Problem:
I'm entering numbers in as a while loop using scanf (inb4 depreciated). When I enter one, the buffer fills the rest in with blank lines.
Code:
double input, total;
for(i=0; i

Goodies
- 4,439
- 3
- 31
- 57
0
votes
1 answer
C FILE* read/write and optional create
I'm attempting to open a file which may or may not exist for read and write access. I'll also need to perform seek operations on this file. The issue I'm having is that the "r" file flag requires that the file exist, the "w" flag discards the…

fredbaba
- 1,466
- 1
- 15
- 26
0
votes
3 answers
How do right read file via stdio? C++
I want to read file via stdio for RapidXML. I used following:
#include
#include
#include
#include
using namespace rapidxml;
int main(int argc, char** argv)
{
FILE *pFile;
pFile =…

Ivan
- 992
- 1
- 10
- 22
-1
votes
1 answer
C++ - my program stops running `freopen` function from
In my main.cpp:
#include
#include "hashtable.h"
int main() {
printf("1hello");
freopen("2.txt", "w", stdout);
printf("2hello");
freopen("1.txt", "r", stdin);
printf("3hello");
int type;
char buffer[1000];int…

Kenny Ynnek
- 57
- 7
-1
votes
1 answer
Edit txt file using library from C
I am facing problems scanning an existing file.
The challenge is that I have a source text file with some strings. I have to scan this file for the word "o'clock", and where I find it, I have to take the word before "o'clock" and enclose it in…

Dsyder
- 13
- 2
-2
votes
3 answers
C++ error invalid conversion from 'char' to 'const char*'
#include
#include
#include
int main(){
char S[10007];
scanf("%[^\n]", S); getchar();
int i = 0;
char u;
while(S[i]){
u = toupper(S[i]);
if(strcmp(u, "I") == 0){
…

waterswell
- 3
- 2
-2
votes
1 answer
c++ Working with Command Line Arguments.. isalpha not working and how to concat together
Hello I'm making a program to display the following if say './prog7x hello there ' was entered as command line argument:
argument 0 is "./prog7x", has length 8, contains 5 alphabetic characters
argument 1 is "hello", has length 5, contains 5…

alpacaness
- 21
- 1
-3
votes
2 answers
What is fflush exactly and what does it do?
I was reading http://www.cplusplus.com/reference/cstdio/fflush/ and I was curious about what it means. According to the website it says:
If the given stream was open for writing (or if it was open for updating and the last i/o operation was an…

Storm
- 17
- 3
-4
votes
1 answer
should I mix C & C++ style I/O in my C++ program?
This question confuses me lot. Because C++ is a superset of C programmer is free to use C's library functions like printf(), scanf() & many others etc. But I usually like C++ 's Object oriented I/O system & I mostly like to use cout & cin. Because…

Destructor
- 14,123
- 11
- 61
- 126