0 / 0 / 0
Регистрация: 09.11.2013
Сообщений: 18
1

Ошибка: [Error] 'x' was not declared in this scope

26.11.2013, 07:33. Показов 5537. Ответов 2
Метки нет (Все метки)

Не могу понять в чём ошибка. Компилятор пишет что в строке cin>>x.name>>x.surname>>x.number; . Ошибка: [Error] 'x' was not declared in this scope. Вот мой код:
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
#include <iostream>
#include <fstream>
 
using namespace std;
struct Abon 
{
char name[50];
char surname[50];
int number;
};
 
int main()
{
    int n;
Abon X;
FILE * f;
f = fopen("structura" , "wb");
cout<<"Vvedite kolichestvo grupp"<<endl;
cin>>n;
for(int i =0;i<n;i++) 
{
    cin>>x.name>>x.surname>>x.number;
    fwrite(&X, sizeof(Abon), 1, f);
}
 
fclose (f);
return 0;
}
0
Programming
Эксперт
94731 / 64177 / 26122
Регистрация: 12.04.2006
Сообщений: 116,782
26.11.2013, 07:33
Ответы с готовыми решениями:

Ошибка [Error] 'ofstream' was not declared in this scope
Дали задание мини БД с записью в файл Но вот ошибка 'ofstream' was not declared in this scope...

Ошибка cpp|7|error: 'itoa' was not declared in this scope
Почему ошибка? #include &lt;stdio.h&gt; #include &lt;stdlib.h&gt; int main(void) { char p; ...

Ошибка: error: 'error' was not declared in this scope
#include &lt;iostream&gt; #include&lt;vector&gt; using namespace std; int area(int a,int b) { if(a&lt;=0...

Ошибка при компиляции error: 'endl' was not declared in this scope
#include &lt;stdio.h&gt; #include &lt;conio.h&gt; void main() { double a, b, x, h, r, s; int n, zn...

2
5494 / 4889 / 831
Регистрация: 04.06.2011
Сообщений: 13,587
26.11.2013, 07:37 2
Компилятор различает строчные и прописные буквы:
Цитата Сообщение от Bloodshed Посмотреть сообщение
Abon X;
Цитата Сообщение от Bloodshed Посмотреть сообщение
cin>>x.name>>x.surname>>x.number;
1
0 / 0 / 0
Регистрация: 09.11.2013
Сообщений: 18
26.11.2013, 08:31  [ТС] 3
Точно. Спасибо
0
IT_Exp
Эксперт
87844 / 49110 / 22898
Регистрация: 17.06.2006
Сообщений: 92,604
26.11.2013, 08:31
Помогаю со студенческими работами здесь

'arr' was not declared in this scope 'sum' was not declared in this scope такие вот ошибки.(
#include &lt;iostream&gt; #include &lt;cstdlib&gt; #include &lt;ctime&gt; using namespace std; int main () { ...

[Error] 'k' was not declared in this scope
#include &lt;iostream&gt; using namespace std; int main() { { int k; char z = { ...

[Error] 'If' was not declared in this scope
Недавно начал изучать Си++. Написал программу почти так же, как в примере из книги. #include...

[Error] 'm' was not declared in this scope
почему программа не видит m,h??? пишет ошибку 'm' was not declared in this scope 'h' was not...


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

Или воспользуйтесь поиском по форуму:
3
Ответ Создать тему
Опции темы

КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2023, CyberForum.ru