so i wrote the code above and i have this error below. I see from here that getline only works with char, i tried to write it in other ways, use cin.. but it stll doesn't work, any sugestions?
i really need help with this..
#include <iostream>
#include <fstream>
#include <cstring>
#include <string>
#include <sstream>
using namespace std;
int main()
{
int n;
double sum[100];
double source[100];
int broj;
ifstream ulaz("dat.txt", ios::in);
if(ulaz.is_open())
{
while(!ulaz.eof())
{
cin.sync();
cin.clear();
ulaz.getline(source,sizeof(source));
broj++;
}
}
ulaz.close();
cout<<"Insert number of days:"<<endl;
cin>>n;
for(int i=0; i<broj; i++)
{
sum[i]=1000*source[i];
sum[i]=sum[i]/source[i+1];
}
cout<<"Result: "<<sum<<endl;
system("pause");
return 0;
}
1>------ Build started: Project: Zadaci_za_1l, Configuration: Debug Win32 ------
1> zadatak2.cpp
1>c:\users\****.cpp(23): error C2664: 'std::basic_istream<_Elem,_Traits> &std::basic_istream<_Elem,_Traits>::getline(_Elem *,std::streamsize)' : cannot convert parameter 1 from 'double [100]' to 'char *'
1> with
1> [
1> _Elem=char,
1> _Traits=std::char_traits<char>
1> ]
1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========