Click here to Skip to main content
15,891,248 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C++
#include 

#include 

using namespace std;
//--------------------------------------------------------------------------------------------------------------
int A[100];
int n;

//----------------------------------------------------------------------------------------------------------
void Skaityti()
{int i;
  ifstream fin("Duomenys6.txt");
  fin >> n;
  //cout > A[i];
  fin.close();
}
//-------------------------------------------------------------------------------------------------------------
{
void Skaityti();

  return 0;
}
//-------------------------------------------------------------------
void Spausdinti()
  {ofstream fout("Rezultatai6.txt");
  fout << " Krituliai (lietus)       " << endl;
  fout << "--------------------------" << endl;
  fout << " Diena Krituliu kiekis(mm)" << endl;
  fout << "--------------------------" << endl;
  for (int i = 0; i < n; i++)
  fout << setw(4) << i + 1 << setw(10) << A[i] << endl;
  fout << "--------------------------" << endl;
  fout.close();
}
{
  Skaityti();
  Spausdinti();
  return 0;
}
//------------------------------------------------------------------------
int Kiekis() {
  int s = 0;
  for (int i = 0; i < n; i++)
    s = s + A[i];
  return s;
}
//-----------------------------------------------------------------------------
int Nelijo() {
  int s = 0;
  for (int i = 0; i < n; i++)
    if (A[i] == 0) s = s + 1;
  return s;
}


What I have tried:

codeblock shows error on 21 line: expected unqualified id before '{' token
34 line: setw was not declared
38 line: expected unqualified id before '{' token
It shows mistakes,but I dont know how to fix it
Posted
Updated 11-Apr-20 2:09am
v2

Line 34: You need to #include <iomanip>, which is where setw is defined.
Line 38: The } on line 37 closes the function Spausdinti. You then have a { at file scope. It looks like it's supposed to be the start of a function, but there's no function signature.
Line 21: Now that I can try to count up to that line number, void Skaityti(); is a function declaration only. Remove the ; if its definition is supposed to be the return 0 that follows.
 
Share this answer
 
v2
Look at your code:
C++
fin.close();
}
//-------------------------------------------------------------------------------------------------------------
{                           <<<<<---- What's this doing here?
void Skaityti();

return 0;
Remove it, and see what happens
Also this:
C++
fout.close();
}
{                           <<<<<---- Eh?
Skaityti();
Spausdinti();
return 0;
}
And do yourself a favour: pick an indentation style as stick with it - you can even use the execrable 1TB if you must as long as you are consistent. Mix'n'match doesn;t make your code any easier to read - and makes problems like this harder to see.
 
Share this answer
 
Try to replace
C++
//-------------------------------------------------------------------------------------------------------------
{
void Skaityti();

  return 0;
}

with
C++
//-------------------------------------------------------------------------------------------------------------
void Skaityti();
{

  return 0;
}
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900