I am working on a polynomial program, from there there is no major problem, first I fill my variable 'e1' value by value, then I reset my counters and do the same process for 'e2' finally I print them, 'e1' is printed correctly, but 'e2' is added 2 times the values
As you can see in the image, the first string that I enter is 'e1' while the second is 'e2', also my valiable is declared as char[8]
I attach the code
#include<stdio.h>
#include<iostream>
#include <sstream>
#include <string.h>
using namespace std;
int main(){
char e1[8] = {};
char e2[8] = {};
int cont = 0;
int gf = 8;
do{
cout<<"x^"<<--gf<<": "; cin>>e1[cont];
cout<<endl;
cont++;
}while(cont != 8);
system("cls");
fflush(stdin);
gf = 8;
cont = 0;
do{
cout<<"x^"<<--gf<<": "; cin>>e2[cont];
cout<<endl;
cont++;
}while(cont != 8);
cout<<e1;
cout<<endl;
cout<<e2;
}
Thank you very much..!! :D
The problem you have is not that the data is duplicated, because if you test your program with different data in the two arrays you will notice that the problem is that when you print the arrays, e1 prints fine, but when you print e2 it not only prints e2, but which prints e2 and e1 together. The solution is to make a loop to print the values of the arrays. Make a loop for each array. The code is the following :)