Topic: reading multiple text files


Author: annpapajohn@gmail.com
Date: Wed, 3 May 2017 08:22:36 -0700 (PDT)
Raw View
------=_Part_3703_439178549.1493824956612
Content-Type: multipart/alternative;
 boundary="----=_Part_3704_1295193203.1493824956612"

------=_Part_3704_1295193203.1493824956612
Content-Type: text/plain; charset=UTF-8

i want to write a program that reads the content of two 2d matrices from
two different text files and then writes their sum in another text
file.here is the progress i've made so far:

*#include <iostream>*
*#include <fstream>*
*using namespace std;*

*int main()*
*{*


*int i,j;*
* int a[5][5]; *
*  ifstream in("matrix_a.txt");*

* for (i=0; i<5; i++)*
*  for (j=0; j<5; j++)*
* {in >> a[i][j];*
* cout << a[i][j] << endl;}*

* in.close();*



* int b[5][5]; *
*  ifstream in("matrix_b.txt");*

* for (i=0; i<5; i++)*
*  for (j=0; j<5; j++)*
* {in >> b[i][j];*
* cout << b[i][j] << endl;}*

* in.close();*


* int sum[5][5];*
* ofstream out("sum.txt");*

*for(i = 0; i < 5; ++i)*
*        {for(j = 0; j < 5; ++j)*
*            {sum[i][j] = a[i][j] + b[i][j];*

*    out << sum [i][j] << endl;}*
* }   *
*    out.close();*

*    return 0;*
*}*


the problem is that after the compilation i get this message :
*---------- Capture Output ----------*
*> "C:\Emerald\gcpp.bat" sum_of_matrices.cpp sum_of_matrices*
*sum_of_matrices.cpp: In function 'int main()':*
*sum_of_matrices.cpp:23:14: error: redeclaration of 'std::ifstream in'*
*   ifstream in("matrix_b.txt");*
*              ^*
*sum_of_matrices.cpp:11:12: note: 'std::ifstream in' previously declared
here*
*   ifstream in("matrix_a.txt");*
*            ^*

*> Terminated with exit code 1.*

can anyone please help me understand the message and how to solve this?

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/87318981-ea9b-4025-99ad-f1a9bca3f272%40isocpp.org.

------=_Part_3704_1295193203.1493824956612
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">i want to write a program that reads the content of two 2d=
 matrices from two different text files and then writes their sum in anothe=
r text file.here is the progress i&#39;ve made so far:<div><br></div><div><=
div><b>#include &lt;iostream&gt;</b></div><div><b>#include &lt;fstream&gt;<=
/b></div><div><b>using namespace std;</b></div><div><b><br></b></div><div><=
b>int main()</b></div><div><b>{</b></div><div><b><br></b></div><div><b><br>=
</b></div><div><b>int i,j;</b></div><div><b>=C2=A0int a[5][5];<span class=
=3D"Apple-tab-span" style=3D"white-space:pre"> </span></b></div><div><b>=C2=
=A0<span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>ifstrea=
m in(&quot;matrix_a.txt&quot;);</b></div><div><b>=C2=A0<span class=3D"Apple=
-tab-span" style=3D"white-space:pre"> </span></b></div><div><b>=C2=A0for (i=
=3D0; i&lt;5; i++)</b></div><div><b>=C2=A0<span class=3D"Apple-tab-span" st=
yle=3D"white-space:pre"> </span>for (j=3D0; j&lt;5; j++)</b></div><div><b>=
=C2=A0{in &gt;&gt; a[i][j];</b></div><div><b>=C2=A0cout &lt;&lt; a[i][j] &l=
t;&lt; endl;}</b></div><div><b>=C2=A0</b></div><div><b>=C2=A0in.close();</b=
></div><div><b>=C2=A0</b></div><div><b>=C2=A0</b></div><div><b><br></b></di=
v><div><b>=C2=A0int b[5][5];<span class=3D"Apple-tab-span" style=3D"white-s=
pace:pre"> </span></b></div><div><b>=C2=A0<span class=3D"Apple-tab-span" st=
yle=3D"white-space:pre"> </span>ifstream in(&quot;matrix_b.txt&quot;);</b><=
/div><div><b>=C2=A0<span class=3D"Apple-tab-span" style=3D"white-space:pre"=
> </span></b></div><div><b>=C2=A0for (i=3D0; i&lt;5; i++)</b></div><div><b>=
=C2=A0<span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>for =
(j=3D0; j&lt;5; j++)</b></div><div><b>=C2=A0{in &gt;&gt; b[i][j];</b></div>=
<div><b>=C2=A0cout &lt;&lt; b[i][j] &lt;&lt; endl;}</b></div><div><b>=C2=A0=
</b></div><div><b>=C2=A0in.close();</b></div><div><b>=C2=A0</b></div><div><=
b>=C2=A0</b></div><div><b>=C2=A0int sum[5][5];</b></div><div><b>=C2=A0ofstr=
eam out(&quot;sum.txt&quot;);</b></div><div><b>=C2=A0<span class=3D"Apple-t=
ab-span" style=3D"white-space:pre"> </span></b></div><div><b>for(i =3D 0; i=
 &lt; 5; ++i)</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 {for(j =3D 0; j =
&lt; 5; ++j)</b></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 {su=
m[i][j] =3D a[i][j] + b[i][j];</b></div><div><b><br></b></div><div><b>=C2=
=A0 =C2=A0<span class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>=
out &lt;&lt; sum [i][j] &lt;&lt; endl;}</b></div><div><b>=C2=A0} =C2=A0<spa=
n class=3D"Apple-tab-span" style=3D"white-space:pre"> </span></b></div><div=
><b>=C2=A0 =C2=A0<span class=3D"Apple-tab-span" style=3D"white-space:pre"> =
</span>out.close();</b></div><div><b>=C2=A0 =C2=A0<span class=3D"Apple-tab-=
span" style=3D"white-space:pre"> </span></b></div><div><b>=C2=A0 =C2=A0<spa=
n class=3D"Apple-tab-span" style=3D"white-space:pre"> </span>return 0;</b><=
/div><div><b>}</b></div></div><div><br></div><div><br></div><div>the proble=
m is that after the compilation i get this message :</div><div><div><b>----=
------ Capture Output ----------</b></div><div><b>&gt; &quot;C:\Emerald\gcp=
p.bat&quot; sum_of_matrices.cpp sum_of_matrices</b></div><div><b>sum_of_mat=
rices.cpp: In function &#39;int main()&#39;:</b></div><div><b>sum_of_matric=
es.cpp:23:14: error: redeclaration of &#39;std::ifstream in&#39;</b></div><=
div><b>=C2=A0 =C2=A0ifstream in(&quot;matrix_b.txt&quot;);</b></div><div><b=
>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^</b></div><div><b>sum_of=
_matrices.cpp:11:12: note: &#39;std::ifstream in&#39; previously declared h=
ere</b></div><div><b>=C2=A0 =C2=A0ifstream in(&quot;matrix_a.txt&quot;);</b=
></div><div><b>=C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 ^</b></div><div><b=
><br></b></div><div><b>&gt; Terminated with exit code 1.</b></div></div><di=
v><br></div><div>can anyone please help me understand the message and how t=
o solve this?</div></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/87318981-ea9b-4025-99ad-f1a9bca3f272%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/87318981-ea9b-4025-99ad-f1a9bca3f272=
%40isocpp.org</a>.<br />

------=_Part_3704_1295193203.1493824956612--

------=_Part_3703_439178549.1493824956612--

.


Author: Nicol Bolas <jmckesson@gmail.com>
Date: Wed, 3 May 2017 08:51:00 -0700 (PDT)
Raw View
------=_Part_3267_953677247.1493826660172
Content-Type: multipart/alternative;
 boundary="----=_Part_3268_1648209338.1493826660172"

------=_Part_3268_1648209338.1493826660172
Content-Type: text/plain; charset=UTF-8

This is not a C++ help forum; it is a forum for discussing proposals for
the C++ language.

--
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp.org/d/msgid/std-proposals/a5fc218b-4c67-404e-809d-af122728f691%40isocpp.org.

------=_Part_3268_1648209338.1493826660172
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">This is not a C++ help forum; it is a forum for discussing=
 proposals for the C++ language.<br></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/a5fc218b-4c67-404e-809d-af122728f691%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/a5fc218b-4c67-404e-809d-af122728f691=
%40isocpp.org</a>.<br />

------=_Part_3268_1648209338.1493826660172--

------=_Part_3267_953677247.1493826660172--

.


Author: annpapajohn@gmail.com
Date: Wed, 3 May 2017 09:04:12 -0700 (PDT)
Raw View
------=_Part_2169_619805954.1493827452730
Content-Type: multipart/alternative;
 boundary="----=_Part_2170_2096543986.1493827452731"

------=_Part_2170_2096543986.1493827452731
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

thanks for the information and sorry for bothering

=CE=A4=CE=B7 =CE=A4=CE=B5=CF=84=CE=AC=CF=81=CF=84=CE=B7, 3 =CE=9C=CE=B1=CE=
=90=CE=BF=CF=85 2017 - 6:51:00 =CE=BC.=CE=BC. UTC+3, =CE=BF =CF=87=CF=81=CE=
=AE=CF=83=CF=84=CE=B7=CF=82 Nicol Bolas =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=
=B5:
>
> This is not a C++ help forum; it is a forum for discussing proposals for=
=20
> the C++ language.
>

--=20
You received this message because you are subscribed to the Google Groups "=
ISO C++ Standard - Future Proposals" group.
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to std-proposals+unsubscribe@isocpp.org.
To post to this group, send email to std-proposals@isocpp.org.
To view this discussion on the web visit https://groups.google.com/a/isocpp=
..org/d/msgid/std-proposals/0546a7ad-b444-49d2-b107-d27a419ec4cd%40isocpp.or=
g.

------=_Part_2170_2096543986.1493827452731
Content-Type: text/html; charset=UTF-8
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">thanks for the information and sorry for bothering<br><br>=
=CE=A4=CE=B7 =CE=A4=CE=B5=CF=84=CE=AC=CF=81=CF=84=CE=B7, 3 =CE=9C=CE=B1=CE=
=90=CE=BF=CF=85 2017 - 6:51:00 =CE=BC.=CE=BC. UTC+3, =CE=BF =CF=87=CF=81=CE=
=AE=CF=83=CF=84=CE=B7=CF=82 Nicol Bolas =CE=AD=CE=B3=CF=81=CE=B1=CF=88=CE=
=B5:<blockquote class=3D"gmail_quote" style=3D"margin: 0;margin-left: 0.8ex=
;border-left: 1px #ccc solid;padding-left: 1ex;"><div dir=3D"ltr">This is n=
ot a C++ help forum; it is a forum for discussing proposals for the C++ lan=
guage.<br></div></blockquote></div>

<p></p>

-- <br />
You received this message because you are subscribed to the Google Groups &=
quot;ISO C++ Standard - Future Proposals&quot; group.<br />
To unsubscribe from this group and stop receiving emails from it, send an e=
mail to <a href=3D"mailto:std-proposals+unsubscribe@isocpp.org">std-proposa=
ls+unsubscribe@isocpp.org</a>.<br />
To post to this group, send email to <a href=3D"mailto:std-proposals@isocpp=
..org">std-proposals@isocpp.org</a>.<br />
To view this discussion on the web visit <a href=3D"https://groups.google.c=
om/a/isocpp.org/d/msgid/std-proposals/0546a7ad-b444-49d2-b107-d27a419ec4cd%=
40isocpp.org?utm_medium=3Demail&utm_source=3Dfooter">https://groups.google.=
com/a/isocpp.org/d/msgid/std-proposals/0546a7ad-b444-49d2-b107-d27a419ec4cd=
%40isocpp.org</a>.<br />

------=_Part_2170_2096543986.1493827452731--

------=_Part_2169_619805954.1493827452730--

.