help

how do i make to put the int "acumulador" on here? :
do{
fflush(stdin);
archivo<<[here]<<endl;
archivo<<"=========="<<endl;
cin>>rpt;
}
it give's me an error
here's the entire code:
(a lot of ints and texts are in spanish because im spanish)

#include <conio.h>
#include <stdio.h>
#include <iostream>
#include <stdlib.h>
#include <fstream>
using namespace std;

void escribirFrases();
int main()
{
void escribirFrases();

char seguir;
int acumulador, contador, numero;

acumulador = 0;
contador = 0;
do
{
printf( "\n Introduzca un n%cmero entero: ", 163 );
scanf( "%d", &numero);

acumulador += numero;
contador++;

printf( "\n %cDesea introducir otro n%cmero (s/n)?: ", 168, 163 );
fflush(stdin);
scanf( "%c", &seguir);
} while ( seguir != 'n' );

printf( "\n Ha introducido %d n%cmero(s).", contador, 163 );
printf( "\n\n La suma de todos ellos es: %d", acumulador );

getch(); /* Pausa */

return 0;
}
void escribirFrases(){
ofstream archivo;
char rpt;

archivo.open("C://Users//***//Desktop//***//Logs/logs.txt",ios::out); //Creamos el archivo

do{
fflush(stdin);
archivo<<acumulador<<endl;
archivo<<"=========="<<endl;
cin>>rpt;
}

archivo.close(); //Cerramos el archivo
}

pastebin : https://pastebin.com/xb1nL3EH
Last edited on
The reason is that the function escribirFrases() does not have a local variable with that name. If you want to use the variable from main() you need to pass it to escribirFrases(). Like so:

void escribirFrases(int acumulador)... // Don't forget to change the prototype as well

By the way: The second void escribirFrases(); does not call this function. It is the prototype the second time.

The first thing you need to decide is whether you're a C programmer or a C++ programmer.

The chaotic mix of modern C++, modern-ish C and archaic DOS-isms isn't doing you any favours.

Oh, and please use https://www.cplusplus.com/articles/jEywvCM9/ code tags when posting code.
Last edited on
Topic archived. No new replies allowed.