Меню

Expected declaration or statement at end of input ошибка

void mi_start_curr_serv(void){
#if 0
 //stmt
#endif    
}

I’m getting an error as «error: expected declaration or statement at end of input» in my compiler. I could not find any error with the above function. Please help me to understand this error.

asked Jan 3, 2012 at 4:15

Angus's user avatar

8

Normally that error occurs when a } was missed somewhere in the code, for example:

void mi_start_curr_serv(void){
    #if 0
    //stmt
    #endif

would fail with this error due to the missing } at the end of the function. The code you posted doesn’t have this error, so it is likely coming from some other part of your source.

answered Jan 3, 2012 at 4:28

DRH's user avatar

DRHDRH

7,75833 silver badges42 bronze badges

8

For me this problem was caused by a missing ) at the end of an if statement in a function called by the function the error was reported as from. Try scrolling up in the output to find the first error reported by the compiler. Fixing that error may fix this error.

answered Jan 28, 2015 at 21:54

user3367083's user avatar

You probably have syntax error.
You most likely forgot to put a } or ; somewhere above this function.

Kami Kaze's user avatar

Kami Kaze

2,05914 silver badges27 bronze badges

answered Aug 2, 2016 at 7:35

wizard of oz's user avatar

2

For me it was a missing } bracket in a function called by the code where the error was reported. Was also reported on code calling the function that called the function missing the }. So can be hard to find if you do not know what you are looking for.

answered May 26, 2021 at 7:20

user3596809's user avatar

user3596809user3596809

411 gold badge1 silver badge6 bronze badges

Try to place a

return 0;

on the end of your code or just erase the

void

from your main function
I hope that I helped

answered Nov 5, 2016 at 22:24

Wojtek's user avatar

For me I just noticed that it was my .h archive with a ‘{‘. Maye that can help someone =)

answered May 21, 2018 at 23:49

Joanderson Gonçalves's user avatar

for anyone who tries to run a mpi program and gets the error above, deleting commends right before or after these symbols { } seem to do the trick.

I have both kali and ubuntu wsl, in kali the program runs fine but in ubuntu i had to delete the comments in order for the program to run

answered Dec 19, 2021 at 14:58

Petros Boufidis's user avatar

1

Home »
C programs »
C common errors programs

Here, we will learn why an error expected declaration or statement at end of input is occurred and how to fix it?

Submitted by IncludeHelp, on September 09, 2018

The main cause of this error is – missing closing curly brace (}) of the main() block.

Example:

#include <stdio.h>

int main(void){
	printf("Hello world");
	return 0;

Output

prog.c: In function ‘main’:
prog.c:5:2: error: expected declaration or statement at end of input
  return 0;
  ^~~~~~

In this program, closing brace of the main() block is missing

How to fix?

To fix this and such errors, please take care of curly braces, they are properly opened and closed.

Correct code:

#include <stdio.h>

int main(void){
	printf("Hello world");
	return 0;
}

Output

Hello world

C Common Errors Programs »


Expected Declaration or statement at end of Input

May be wrong:
1. A function or variable is not declared before it is used.
2. A parenthesis is missing somewhere.

Read More:

  • C language error – [error] expected declaration or statemt at end of input— solution.
  • error: expected declaration or statement at end of input
  • error: a label can only be part of a statement and a declaration is not a statement (How to Fix)
  • Error c2951: template declaration can only be used at the global, namespace, or class scope. Error c2598: link specification must be at the global scope
  • error C2057: expected constant expression (Can the size of an array in C language be defined when the program is running?)
  • C language string processing error warning, c4996, sprintf, predicted, c4996, strcpy, c4996, strcat
  • 【.Net Core】using declarations‘ is not available in C# 7.3. Please use language version 8.0 or greate
  • error: declaration may not appear after executable statement in block
  • Unity “Feature `out variable declaration’ cannot be used because it is not part of the C# 4.0” error
  • Error c2137 of C language: empty character constant (Fixed)
  • When C language refers to a user-defined type as a parameter, an error segmentation fault is reported
  • [!] Invalid `Podfile` file: syntax error, unexpected end-of-input, expecting keyword_end.
  • Solution to error [error] LD returned 1 exit status in C language
  • On the coercion of C language
  • raise ValueError(‘Expected input batch_size ({}) to match target batch_size ({}).‘
  • C language — to solve the problem of program flashback when programming (in VS)
  • The function and usage of argc and argv in C language
  • No qualifying bean of type ‘javax.sql.DataSource‘ available: expected at least 1
  • Explain stdin, stdout, stderr in C language
  • ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256,
  • Home
  • Forum
  • General Programming Boards
  • C Programming
  • error:expected declaration or statement at end of input

  1. 09-20-2007


    #1

    alzar is offline


    Registered User


    linked list and read strings-problem

    GO TO POST 6(is my new problem)
    {
    this solved
    I am getting this message when i am trying to compile the code
    series1.c:44: σφάλμα: expected declaration or statement at end of input
    series1.c:44: σφάλμα: expected declaration or statement at end of input
    where is the mistake?(maybe any missing { or })

    Code:

    #include <stdio.h>
    #include <stdlib.h>
    
    struct node{
      char data[64];
      struct node *next;
     };
    struct node *firsta, *currenta, *newa;
    
    int main(void)
    {
     int k;
     scanf("%d", &k);
    
     struct node *head=NULL;
    
     do{
      switch(k){
       case 1: addnew();
       break;
    
      }while(k!=0);
    
     void addnew(void)
    {
     struct node *newnode=malloc(sizeof(struct node));
      
     if (head=NULL) 
      firsta=newa=currenta;
     else
     {
      currenta=firsta;
       while(currenta->next!=NULL)
        currenta=currenta->next;
    
       currenta->next=newa;
       currenta=newa;
    }
    
    gets(currenta->data);
    
    currenta->next=NULL;
    }

    }SOLVED

    Last edited by alzar; 09-20-2007 at 12:23 PM.


  2. 09-20-2007


    #2

    matsp is offline


    Kernel hacker


    If you indent your code correctly, you’ll notice that you are missing two curly braces…


    Mats

    Compilers can produce warnings — make the compiler programmers happy: Use them!
    Please don’t PM me for help — and no, I don’t do help over instant messengers.


  3. 09-20-2007


    #3

    Salem is offline


    and the hat of int overfl

    Salem's Avatar


    Count the number of closing braces which your main() seems to have.

    Read the FAQ on why you shouldn’t use gets()


  4. 09-20-2007


    #4

    alzar is offline


    Registered User


    Quote Originally Posted by alzar
    View Post

    I am getting this message when i am trying to compile the code
    series1.c:44: σφάλμα: expected declaration or statement at end of input
    series1.c:44: σφάλμα: expected declaration or statement at end of input
    where is the mistake?(maybe any missing { or })

    Code:

    #include <stdio.h>
    #include <stdlib.h>
    
    struct node{
      char data[64];
      struct node *next;
     };
    struct node *firsta, *currenta, *newa;
    
    int main(void)
    {
     int k;
     scanf("%d", &k);
    
     struct node *head=NULL;
    
     do{
      switch(k){
       case 1: addnew();
       break;
        }
      }while(k!=0);
      
    return 0;
    }
     void addnew(void)
    {
     struct node *newnode=malloc(sizeof(struct node));
      
     if (head=NULL) 
      firsta=newa=currenta;
     else
     {
      currenta=firsta;
       while(currenta->next!=NULL)
        currenta=currenta->next;
    
       currenta->next=newa;
       currenta=newa;
    }
    
    gets(currenta->data);
    
    currenta->next=NULL;
    }

    This code was a part of an exercise that i have, so i forget to close switch and main.Sorry


  5. 09-20-2007


    #5

    hk_mp5kpdw is offline


    Registered User

    hk_mp5kpdw's Avatar


    Code:

    int main(void)
    {
        int k;
        scanf("%d", &k);
    
        struct node *head=NULL;
    
        do {
            switch(k) {
            case 1:
                addnew();
                break;
            }
        } while(k!=0);

    This is an infinite loop if k is anything other than 0. There is no modification of k beyond the initial scanf call.

    Code:

    void addnew(void)
    {
        struct node *newnode=malloc(sizeof(struct node));
      
        if (head=NULL) 
            firsta=newa=currenta;

    = is for assignment, == is to test for equality. Second, head is not in scope here. Third, currenta hasn’t yet been initialized the first time the function is called, head is equal to NULL and in fact does not change it’s value so it will always be NULL and the rest of the code (the else part) will never get executed.

    Code:

        else
        {
            currenta=firsta;
            while(currenta->next!=NULL)
                currenta=currenta->next;
    
            currenta->next=newa;
            currenta=newa;
        }
    
        gets(currenta->data);
    
        currenta->next=NULL;
    }

    newa never gets initialized to anything valid (in the above if test it is effectively set to the same random address as currenta). Same thing with firsta and since currenta points to this random memory address I certainly wouldn’t want to try and access its next pointer member. I think newa is really supposed to be newnode here in this function and firsta is maybe supposed to be set to head which gets passed in as a parameter?

    The whole function should either be returning a pointer to a new node, or setting an argument passed into the function to the newly allocated memory, or something like that. Bottom line is there’s a lot wrong with this code that needs fixing.

    «Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods.»
    -Christopher Hitchens


  6. 09-20-2007


    #6

    alzar is offline


    Registered User


    @hk_mp5kpdw
    i make some changes. What’s wrong?

    Code:

    #include <stdio.h>
    #include <stdlib.h>
    
    struct node{
      char data[64];
      struct node *next;
     };
    struct node *firsta, *currenta, *newa;
     void addnew(void);
    
    int main(void)
    {
     int k;
    
    firsta=NULL;
    
     do{
     fflush(stdin);  
     printf("enter a choicen");
     scanf("%d", &k);
      switch(k){
       case 1: 
       printf("enter string");
       fflush(stdin); 
       addnew();
       break;}
    
      }while(k!=0);
    return 0;
    }
     void addnew(void)
    {
     newa=(struct node *)malloc(sizeof(struct node));
      
     if (firsta==NULL) 
      firsta=currenta=newa;
     else
     {
      currenta=firsta;
       while(currenta->next!=NULL)
        currenta=currenta->next;
    
       currenta->next=newa;
       currenta=newa;
     }
    
    gets(currenta->data);
    
    currenta->next=NULL;
    }

    I am getting something like this
    enter a choice
    1
    enter stringenter a choice
    1
    enter stringenter a choice
    asd
    enter stringenter a choice
    0
    owner@owner-laptop

    Last edited by alzar; 09-20-2007 at 12:18 PM.


  7. 09-20-2007


    #7

    matsp is offline


    Kernel hacker


    Not what you wnat to do. Check the FAQ for «How do I clear the input buffer» or some such.


    Mats

    Compilers can produce warnings — make the compiler programmers happy: Use them!
    Please don’t PM me for help — and no, I don’t do help over instant messengers.


  8. 09-20-2007


    #8

    alzar is offline


    Registered User


    i found only this
    http://faq.cprogramming.com/cgi-bin/…&id=1043284351
    should i replace fflush with something?if yes with what?
    or just remove it from the code?


  9. 09-20-2007


    #9

    matsp is offline


    Kernel hacker


    Quote Originally Posted by alzar
    View Post

    No, another bit further down:
    http://faq.cprogramming.com/cgi-bin/…&id=1043284392


    Mats

    Compilers can produce warnings — make the compiler programmers happy: Use them!
    Please don’t PM me for help — and no, I don’t do help over instant messengers.


  10. 09-20-2007


    #10

    vart is offline


    Hurry Slowly

    vart's Avatar


    1. you should not cast malloc (see FAQ)
    2. you HAVE TO check the return value of malloc
    3. you SHOULD NOT use gets (see FAQ)
    4. Why do you need currenta and newa as globals? Make the local for addnew
    5. better to make *firsta local for main and pass it as a parameter to addnew (pointer to it actually to be able to modify it)
    6. do not forget to free the list before you exit the program

    All problems in computer science can be solved by another level of indirection,
    except for the problem of too many layers of indirection.
    � David J. Wheeler


  11. 09-21-2007


    #11

    alzar is offline


    Registered User


    @matsp
    Thank you so much.I didn’t know that fflush is so dangerous.I replace the fflush with
    while ((ch = getchar()) != ‘n’ && ch != EOF);
    but now i have another problem look:

    PHP Code:


    owner@owner-laptop:~$ ./series1
                            
    /*the first time i must enter in order to print me the"enter choice"*/
    enter a choice
    1
    enter string
    hello there

    enter a choice



    Is there a way not to have this problem?(look in my edit down here in this post)

    ps:in the link you gave me the BUFSIZ where is? In stdio.h?

    @vart
    thank you.I know all of them but this not the finally code.I will make some of the changes you tell me in the end and also the addnew function must have no arguments.

    edit:i delete the first while and i haven’t this problem,but maybe is necessary ?i don’t know.In the book where i saw the code it cleans the input also before enter choice

    note:there is also other cases after, such as delete an element of the list or print an element

    Last edited by alzar; 09-21-2007 at 01:29 AM.


  12. 09-21-2007


    #12

    matsp is offline


    Kernel hacker


    You can’t just «flush» the input buffer if there’s nothing there. You’ll need to try to get something first, then flush if you think the user input more than you wanted. [But better make SURE that this is the case, otherwise it will be the same problem].


    Mats

    Compilers can produce warnings — make the compiler programmers happy: Use them!
    Please don’t PM me for help — and no, I don’t do help over instant messengers.


  13. 09-22-2007


    #13

    alzar is offline


    Registered User


    i update my post and still have some problems with what it prints me
    case 1 is to add a newnode
    case 2 to print the list
    case 3 to print one element(asks to give an index) of the list and delete it
    case 4 to find the length of a string that i gave his index

    it prints me
    enter a choice
    1
    enter string
    hello
    enter a choice
    1
    enter string
    there

    enter a choice
    you
    enter string

    so in enter choice i write «you» and then it didn’t tell me again enter choice but enter string.why?
    the hole code(a little big)

    Code:

    #include <stdio.h>
    #include <stdlib.h>
    #include <ctype.h>
    #include <string.h>
    
    struct node{
      char data[64];
      struct node *next;
     };
    struct node *firsta, *currenta, *newa;
     
    void addnew(void);
    void printall(struct node *head);
    void printanddelete( int i);
    int findlen(int j);
    int slen(char *p);
    
    int main(void)
    {
     int k,i,j,m;
     char ch;
    firsta=NULL;
    
     do{
     printf("enter a choicen");
     scanf("%d", &k);
      switch(k){
       case 1: 
       printf("enter stringn");
       while ((ch = getchar()) != 'n' && ch != EOF);
       addnew();
       break;
       
       case 2:
       printall(firsta);
       break;
    
       case 3:
        printf("enter a number");
        scanf("%d", &i);
        printanddelete(i);
        break;
       case 4:
        printf("enter index to  find length");
        scanf("%d", &j);
        m=findlen(j);
        printf("%d", m);}
      }while(k!=0);
    return 0;
    }
     void addnew(void)
    {
     newa=(struct node *)malloc(sizeof(struct node));
      
     if (firsta==NULL) 
      firsta=currenta=newa;
     else
     {
      currenta=firsta;
       while(currenta->next!=NULL)
        currenta=currenta->next;
    
       currenta->next=newa;
       currenta=newa;
     }
    
    gets(currenta->data);
    
    currenta->next=NULL;
    }
    
    void printall(struct node *head)
    {
     struct node *current=head;
    
     if(head==NULL)
      return;
    
      while(current!=NULL)
       {printf(current->data);
        printf("n");
        current=current->next;
    
        }
        printf("~");
    }
    
    
    void printanddelete( int i)
    {
     int index=1;
     struct node *current=firsta;
     struct node *prev;
    
     while (current!=NULL){
      if(i==index)
       {printf(current->data);
        if(current==firsta) 
          firsta=current->next;
         else
          prev=current->next;
    
        free(current);
        current=prev;
        break;}
      else{
      index++;
      current=current->next;}
      }
    }
    
    int findlen(int j)
    {
      struct node *current=firsta;
      int index=1;
      int l;
      
      while (current!=NULL){
        if (j==index)
          return(slen(current->data));
        else
          index++;
          current=current->next;  
       }
    }
    
    
    int slen(char *p)
    {
     if (*p=='')
       return 0;
     else
       return(slen(++p) +1);
    }

    Last edited by alzar; 09-22-2007 at 03:21 AM.


  14. 09-22-2007


    #14

    alzar is offline


    Registered User



Popular pages

  • Exactly how to get started with C++ (or C) today
  • C Tutorial
  • C++ Tutorial
  • 5 ways you can learn to program faster
  • The 5 Most Common Problems New Programmers Face
  • How to set up a compiler
  • 8 Common programming Mistakes
  • What is C++11?
  • Creating a game, from start to finish

Recent additions subscribe to a feed

  • How to create a shared library on Linux with GCC — December 30, 2011
  • Enum classes and nullptr in C++11 — November 27, 2011
  • Learn about The Hash Table — November 20, 2011
  • Rvalue References and Move Semantics in C++11 — November 13, 2011
  • C and C++ for Java Programmers — November 5, 2011
  • A Gentle Introduction to C++ IO Streams — October 10, 2011

Similar Threads

  1. Replies: 4

    Last Post: 06-05-2002, 09:41 AM

  2. Replies: 3

    Last Post: 06-02-2002, 09:22 AM

  3. Replies: 2

    Last Post: 05-10-2002, 04:16 PM

  4. Replies: 4

    Last Post: 11-01-2001, 04:49 PM

  5. Replies: 7

    Last Post: 10-20-2001, 04:18 PM

The curly braces in writecharatpos don’t add up.

To find errors of that kind, paste your original code into a tool with source formatting help, and autoformat your code.

The error will become clear at first sight once formatted: The main function is not on column one, meaning the some earlier function is not correctly closed. Also, the first search result on the error message says «curly braces dont add up».

Formating your code is considered good practice. It helps you, and others who you ask about your code. I format code while typing, and regularly autoformat it too.

You might also consider a naming policy like CamelCasing or so, because WriteCharAtPos is so much better to read.

Commenting code, especially port-fiddling, is also considered good practice.

Some comment on what the delays are good for in initialization, for instance, would be nice. Also comment on what is being intented to be written to the port. You’ll thank yourself in 2 years, when you take a look at the library because you notice you have to change it one day.

Comments like _delay_ms(3); //3 are useless. Comment why, not what is done.

Лизаветка

1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

1

01.05.2017, 21:41. Показов 35433. Ответов 13

Метки нет (Все метки)


Посмотрите, пожалуйста. Выдает ошибку expected ‘}’ at end of input, но скобки везде попарно

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
int main()
{
    setlocale(LC_ALL, "Russian");
    inform();
    getch();
    system("cls");//новая страница
    char zapros_menu, vspom_zapr;
    glavnoe_menu();
    vspom_zapr=zapr_menu();
    int otvet;
    while (vspom_zapr!='0')
    {
        zapros_menu=vspom_zapr;
        system("cls");
        switch (zapros_menu)
        {
        case '1':
            {
                svedenia_po_program();
            }
        case '2':
            {
                otvet=TEORIA::demonstrate();
            }
        case '3':
            {
 
            }
        case '4':
            {
 
            }
        case '5':
            {
 
            }
        };
        getch();
        system("cls");
        glavnoe_menu();
        if (otvet==0)
        {
            vspom_zapr=0;
        } else
        {
            vspom_zapr=zapr_menu();
        };
    };
    return 0;
}

__________________
Помощь в написании контрольных, курсовых и дипломных работ, диссертаций здесь



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 21:53

2

а на какой строке вылетает ошибка?



0



284 / 232 / 114

Регистрация: 07.09.2016

Сообщений: 584

01.05.2017, 21:57

3

привыкайте нормально код форматировать. черт ногу сломит в такой писанине.
по ошибке: если это студия и в начале файла нет #include «stdafx.h» — то в этом может быть причина.
может есть другой код, который вы не написали тут, но он есть. например тут нед вообще ни
одного инклуда, что там у вас еще есть, чего вы не запостили известно только вам.



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 21:59

4

Во-первых, если операция только одна, то операторные скобки необязательны (хотя бы не запутаетесь)
Во-вторых, так как Вы не привели полный код программы, откуда нам знать, что эта ошибка не возникает во всяких подпрограммах типа zapr_menu()?



0



Лизаветка

1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

01.05.2017, 22:07

 [ТС]

5

вот полный код программы, выдает ошибку в последней строке, пробовала убирать частично код программы, ошибка уходит, если только убрать строки #include «teoria.h» и #include «teoria.cpp, выходит ошибка в них

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#include <iostream>
#include <fstream>
#include <conio.h>
#include <stdlib.h>
#include <string>
 
#include "teoria.h"
 
#include "teoria.cpp"
 
using namespace std;
 
void inform()
{
    cout << "n"
    "        Астраханский государственный технический университетn"
    "          Институт Информационных технологий и коммуникацийnnn"
    "                                                Кафедраn"
    "                                                Автоматизированных системn"
    "                                                бработки информации и управленияnnnnn"
    "                     Курсовая работа по дисциплинеn"
    "                   'Программирование и информатика'n"
    "        Учебно - демонстрационная программа <<Сортировка Бэтчера>>nnnn"//свет
    "                                                Выполнила: студентка группы ДИНРб-11n"
    "                                                Бондаренко Е. М.n"//свет
    "                                                Руководитель работыn"
    "                                                Ст. преп. Толасова В. В.nnnnn"
    "                          г.АСТРАХАНЬ  2017г.nn ";
};
 
void glavnoe_menu()
{
    cout << "nn     Учебно-демонстрационная программа <<Cортировка Бэтчера>> n";//свет
    cout << "nnn*************************";
    cout << "<Главное Меню>";//свет
    cout <<    "****************************nn" <<endl;
    cout << "                                                   клавишаnn";
    cout << "            Сведения о работе программы..............";
    cout << " 1nn";//свет
    cout << "            Теоретический материал...................";
    cout << " 2nn";//свет
    cout << "            Пошаговая демонстрация сортировки........";
    cout << " 3nn";//свет
    cout << "            Тест по пройденному материалу............";
    cout << " 4nn";//свет
    cout << "            Зайти как администратор..................";
    cout << " 5nn";//свет
    cout << "            Выход....................................";
    cout << " 0nn";//свет
};
 
char zapr_menu()
{
    char zapr;
    cin >> zapr;
    while (zapr!='0' && zapr!='1' && zapr!='2' && zapr!='3' && zapr!='4' && zapr!='5')
    {
        cout << "nНекорректный ввод! Повторите!n";
        cin >> zapr;
    };
    return zapr;
};
 
void svedenia_po_program()
{
    ifstream out("svedenia.txt");
    if(out.is_open())
    {
        while (!out.eof())
        {
            string stroka;
            getline(out, stroka, 'n');
            cout << "n   " << stroka;
        }
    };
    out.close();
};
 
int main()
{
        setlocale(LC_ALL, "Russian");
    inform();
    getch();
    system("cls");//новая страница
    char zapros_menu, vspom_zapr;
    glavnoe_menu();
        vspom_zapr=zapr_menu();
         int otvet;
    while (vspom_zapr!='0')
        {
             zapros_menu=vspom_zapr;
             system("cls");
             switch (zapros_menu)
            {
            case '1':
                {
                       svedenia_po_program();
                }
            case '2':
               {
                      otvet=TEORIA::demonstrate();
                }
            case '3':
               {
 
                }
            case '4':
               {
 
                }
             case '5':
               {
 
                }
        };
        getch();
        system("cls");
        glavnoe_menu();
        if (otvet==0)
        {
            vspom_zapr=0;
        } else vspom_zapr=zapr_menu();
    };
    return 0;
}



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 22:11

6

Цитата
Сообщение от Лизаветка
Посмотреть сообщение

#include «teoria.cpp»

что значит #include исходный код C++? Вы подключаете и хедер teoria.h и исходник teoria.cpp



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 22:12

7

И учитесь уже обрамлять код тегами [CPP]

Миниатюры

ошибка expected '}' at end of input
 



0



1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

01.05.2017, 22:15

 [ТС]

8

спасибо, впредь буду оформлять нормально, это мои первые 15 минут на данном форуме)



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 22:16

9

Лизаветка, ну а насчет инклюдов Вы поняли?



0



Лизаветка

1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

01.05.2017, 22:20

 [ТС]

10

нет. я подключаю и то и то, без хедера ошибка остается.
вот что у меня представляет teoria.cpp

C++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "teoria.h"
 
#include <iostream>
#include <fstream>
#include <ctime>
#include <conio.h>
#include <windows.h>
 
using namespace std;
 
namespace TEORIA
{
 
    void mini_menu()
    {
        cout << "nn                                          клавишаnn";
        cout << "            Назад...........................";
        cout << " 1n";//свет
        cout << "            Вперед..........................";
        cout << " 2n";//свет
        cout << "            Главное меню....................";
        cout << " 3n";//свет
        cout << "            Выход...........................";
        cout << " 0n";//свет
    }
 
    char numb_menu()
    {
        char zap;
        cin >> zap;
        while(zap!='1' && zap!='2' && zap!='3' && zap!='0')
        {
            cout << "nНекорректный ввод! Повторите!n";
            cin >> zap;
        };
        return zap;
    }
 
    void display_str(char* name)
    {
        ifstream str(name);
        if(str.is_open())
        {
            while (!str.eof())
            {
                string stroka;
                getline(str, stroka, 'n');
                cout << "n   " << stroka;
            }
        };
        str.close();
    }
 
    int demonstrate()
    {
        char dop_zapr='1';
        char zapros_menu='1';
        int otvet;
        do
        {
            switch (dop_zapr)
            {
            case '1':
                {
                    char name[20]="teor_1.txt";
                    display_str(name);
                }
            case '2':
                {
                    char name[20]="teor_2.txt";
                    display_str(name);
                }
            case '3':
                {
                    char name[20]="teor_3.txt";
                    display_str(name);
                }
            case '4':
                {
                    char name[20]="teor_4.txt";
                    display_str(name);
                }
            }
            mini_menu();
            zapros_menu=numb_menu();
            if (zapros_menu=='1')
            {
                dop_zapr++;
            } else dop_zapr--;
        } while (zapros_menu!='3' && zapros_menu!='0' && dop_zapr!='5' && dop_zapr!='0');
        if (zapros_menu=='0') otvet=0; else otvet=1;
        return otvet;
}

и вот teoria.h

C++
1
2
3
4
5
6
7
8
9
10
11
#ifndef TEORIA_H_INCLUDED
#define TEORIA_H_INCLUDED
 
namespace TEORIA
{
    void mini_menu();
    char numb_menu();
    void display_str(char name);
    int demonstrate();
}
#endif // TEORIA_H_INCLUDED

Что нужно убрать?



0



Джоуи

1073 / 635 / 240

Регистрация: 05.05.2015

Сообщений: 3,546

Записей в блоге: 2

01.05.2017, 22:22

11

Лизаветка, вопрос остается прежним: на какой строке и в каком файле возникает ошибка? Можно скриншот скинуть, если сами не разбираетесь



0



DU3

284 / 232 / 114

Регистрация: 07.09.2016

Сообщений: 584

01.05.2017, 22:24

12

Лучший ответ Сообщение было отмечено Лизаветка как решение

Решение

нормально форматируйте не только тут на форуме, но и у себя в редакторе и такого рода проблем будет на порядок меньше.
подозреваю что в teoria.cpp нет закрывающей скобки от

C++
1
2
namespace TEORIA
{



1



Joey

01.05.2017, 22:29

Не по теме:

DU3, ждем ебилдов ТС



0



1 / 1 / 0

Регистрация: 01.05.2017

Сообщений: 34

01.05.2017, 22:35

 [ТС]

14

Спасибо за ответы) ошибка выволилась на последней строке основной программы, оказалось нет закрывабщейся скобки в файле teoria.cpp , спасибо за вопросы, буду работать над оформлением��



1



IT_Exp

Эксперт

87844 / 49110 / 22898

Регистрация: 17.06.2006

Сообщений: 92,604

01.05.2017, 22:35

Помогаю со студенческими работами здесь

Ошибка: Expected END but received ELSE
Всем привет , кто может помочь?!) строка 59 ругается на else. (expected END but received ELSE).

Ошибка: ‘END’ expected but ‘ELSE’ found
Задание:
Написать программу, которая бы по введенному номеру времени года (1 — зима, 2 — весна, 3…

Ошибка: ‘END’ expected but ‘UNTIL’ found
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics,…

Ошибка ‘Expected END but recieved’
Понимаю,что ошибка связанная с begin и end,но я не догоняю,где пропущеноunit Unit2;

interface

Искать еще темы с ответами

Или воспользуйтесь поиском по форуму:

14

0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии

А вот еще интересные материалы:

  • Яшка сломя голову остановился исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного исправьте ошибки
  • Ясность цели позволяет целеустремленно добиваться намеченного где ошибка
  • Excel условное форматирование если ошибка
  • Excel суммпроизв ошибка знач