Форум программистов, компьютерный форум, киберфорум
C для начинающих
Войти
Регистрация
Восстановить пароль
Блоги Сообщество Поиск Заказать работу  
 
Рейтинг 5.00/3: Рейтинг темы: голосов - 3, средняя оценка - 5.00
0 / 0 / 0
Регистрация: 20.10.2022
Сообщений: 41

Указатели. Ошибка "Operands of '*' have incompatible types"

24.12.2022, 00:30. Показов 694. Ответов 4

Студворк — интернет-сервис помощи студентам
помогите разобраться в решении задачи
что можно сделать с этими ошибками,как преобразовать?
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
/* 32 Два отрезка на плоскости заданы координатами своих концов. Определить, имеют ли эти отрезки общие точки.*/
 
#include <stdio.h>
#include <locale.h>
 #include <stdlib.h>
struct txt{
 
int* x1;
    int* y1;
    int* x2;
    int* y2;
    int* x3;
    int* y3;
    int* x4;
    int* y4;
 
};
 
int main ()
    {
FILE *fil=fopen("segmentin.txt","r"); 
    
struct txt t;
    t.x1=0;
    t.x2=0;
    t.y1=0;
    t.y2=0;
    t.x3=0;
    t.y3=0;
    t.x4=0;
    t.y4=0;
fscanf(fil,"%d",t.x1);
fscanf(fil,"%d", t.y1);
fscanf(fil,"%d",t.x2);
fscanf(fil,"%d",t.y2);
fscanf(fil,"%d",t.x3);
fscanf(fil,"%d",t.y3);
fscanf(fil,"%d",t.x4);
fscanf(fil,"%d",t.y4);
fclose(fil);
    
    
 
 
 
    
        
 
    {
        int a = t.x2 - t.x1,
            b = t.y2 - t.y1,
            c = t.x4 - t.x3,
            d = t.y4 - t.y3;
        if (c == 0 && t.x3>=t.x1 && t.x3<=t.x2 && (t.y3<=t.y1 || t.y3<=t.y2)) //Если второй отрезок перпендикулярен ОХ получаем деление на 0
        {
            char s[5] ="Yes";
            FILE *file= fopen("segmentout.txt","w");
                fputs(s,file);
                fclose(file);
        }
        else
        {
            int x = (&b*&c*t.x1 - &a*&c*t.y1 - &a*&d*t.x3+&a*&c*t.y3) / (int)(b*c - a*d),
                    y = ((d*x-d*t.x3)+c*t.y3) / (int*)c;
            //(x, y) точка пересечения прямых
            //проверяем принадлежит ли пересечение нашим отрезкам
            if ((&x>=t.x1 && &x<=t.x2 && &x>=t.x3 && &x<=t.x4) &&
                (((&y>=t.y1 && &y<=t.y2) || (&y<=t.y1 && &y>=t.y2)) && ((&y>=t.y3 && &y<=t.y4) || (&y<=t.y3 && &y>=t.y4))))
            {
                char s[5] ="Yes";
                FILE *file= fopen("segmentout.txt","w");
                fputs(s,file);
                fclose(file);
            }
            else
            {
                char g[5]="No";
                FILE *file =fopen("segmentout.txt","w");
                fputs(g,file);
                fclose(file);;
            }
        }
    }
 
}
вылазят такие ошибки:
Building 32 exp 2.obj.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(21): warning #2117: Old-style function definition for 'main'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int *' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int *' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int *' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int *' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(65): error #2168: Operands of '*' have incompatible types 'int' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(65): error #2168: Operands of '*' have incompatible types 'int' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(65): error #2168: Operands of '/' have incompatible types 'int' and 'int *'.
*** Error code: 1 ***
Done.
0
Лучшие ответы (1)
IT_Exp
Эксперт
34794 / 4073 / 2104
Регистрация: 17.06.2006
Сообщений: 32,602
Блог
24.12.2022, 00:30
Ответы с готовыми решениями:

Ошибка: invalid operands of types 'double' and 'int' to binary 'operator%'
Я писал программу и решил скомпилировать. В этих строках возникли ошибки. n = rint((a / pow(10, i))) % 10; o = a % rint(pow(10,i)); ...

Ошибка Incompatible types
Здраствуйте. Немогу понять почему появляеться ошибка Incompatible types. var dMass:array of array of integer;...

Ошибка Incompatible types
Кто может подсказать что это за ошибка и как её исправить? UnitStydenti.pas(112): Incompatible types: 'TTable' and 'TDataSetState' ...

4
Просто Лис
Эксперт Python
 Аватар для Рыжий Лис
5972 / 3734 / 1099
Регистрация: 17.05.2012
Сообщений: 10,791
Записей в блоге: 9
24.12.2022, 06:54
Может, написать так?
C
1
2
3
4
5
6
7
8
9
10
struct txt{
    int x1;
    int y1;
    int x2;
    int y2;
    int x3;
    int y3;
    int x4;
    int y4;
};
Добавлено через 40 секунд
И так:
C
1
fscanf(fil, "%d", &t.x1);
0
0 / 0 / 0
Регистрация: 20.10.2022
Сообщений: 41
24.12.2022, 11:00  [ТС]
программа шлет меня куда подальше...
Building 32 exp 2.obj.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(21): warning #2117: Old-style function definition for 'main'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int *' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int *' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int *' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(64): error #2168: Operands of '*' have incompatible types 'int *' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(65): error #2168: Operands of '/' have incompatible types 'int' and 'int *'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(68): error #2168: Operands of '>=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(68): error #2168: Operands of '<=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(68): error #2168: Operands of '>=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(68): error #2168: Operands of '<=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(69): error #2168: Operands of '>=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(69): error #2168: Operands of '<=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(69): error #2168: Operands of '<=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(69): error #2168: Operands of '>=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(69): error #2168: Operands of '>=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(69): error #2168: Operands of '<=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(69): error #2168: Operands of '<=' have incompatible types 'int *' and 'int'.
C:\Users\sh\Documents\Pelles C Projects\32 exp 2\32 exp 2.c(69): error #2168: Operands of '>=' have incompatible types 'int *' and 'int'.
*** Error code: 1 ***
Done.
0
Просто Лис
Эксперт Python
 Аватар для Рыжий Лис
5972 / 3734 / 1099
Регистрация: 17.05.2012
Сообщений: 10,791
Записей в блоге: 9
24.12.2022, 11:04
Лучший ответ Сообщение было отмечено kirill14556 как решение

Решение

Цитата Сообщение от kirill14556 Посмотреть сообщение
int x = (&b*&c*t.x1 - &a*&c*t.y1 - &a*&d*t.x3+&a*&c*t.y3) / (int)(b*c - a*d),
                    y = ((d*x-d*t.x3)+c*t.y3) / (int*)c;

Нафига здеcь &&&&&&&&&&&&&&&&&&?

Добавлено через 1 минуту
Цитата Сообщение от kirill14556 Посмотреть сообщение
(int*)c
И это.
1
0 / 0 / 0
Регистрация: 20.10.2022
Сообщений: 41
24.12.2022, 11:15  [ТС]
спасибо за помощь!
0
Надоела реклама? Зарегистрируйтесь и она исчезнет полностью.
BasicMan
Эксперт
29316 / 5623 / 2384
Регистрация: 17.02.2009
Сообщений: 30,364
Блог
24.12.2022, 11:15
Помогаю со студенческими работами здесь

Ошибка: incompatible types
; Ошибка incompatible types 'string' and 'tpicture'; Я новичок. У меня возникла проблема, которую как бы я не бился выходные, не смог...

Ошибка: Incompatible types
Помогите, ошибка Project2.dpr(15): Incompatible types в 15 строке formatSettings.LongMonthNames:= months; Вот программа ...

Ошибка: Incompatible types
TAnimate = class(TBase) private bitmap: array of TBitmap; curFrame: integer; maxFrame: integer; public...

Ошибка incompatible types
Хочу создать файл по кнопке, при компиляции выдаёт ошибку incompatible types procedure TForm1.btn5Click(Sender: TObject); var...

Ошибка: Incompatible types
В общем пишу курсовую и множество вопросов, например сейчас столкнулся с проблемой, подскажите как ее решить. unit Unit6; interface ...


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

Или воспользуйтесь поиском по форуму:
5
Ответ Создать тему
Новые блоги и статьи
Новый ноутбук
volvo 07.12.2025
Всем привет. По скидке в "черную пятницу" взял себе новый ноутбук Lenovo ThinkBook 16 G7 на Амазоне: Ryzen 5 7533HS 64 Gb DDR5 1Tb NVMe 16" Full HD Display Win11 Pro
Музыка, написанная Искусственным Интеллектом
volvo 04.12.2025
Всем привет. Некоторое время назад меня заинтересовало, что уже умеет ИИ в плане написания музыки для песен, и, собственно, исполнения этих самых песен. Стихов у нас много, уже вышли 4 книги, еще 3. . .
От async/await к виртуальным потокам в Python
IndentationError 23.11.2025
Армин Ронахер поставил под сомнение async/ await. Создатель Flask заявляет: цветные функции - провал, виртуальные потоки - решение. Не threading-динозавры, а новое поколение лёгких потоков. Откат?. . .
Поиск "дружественных имён" СОМ портов
Argus19 22.11.2025
Поиск "дружественных имён" СОМ портов На странице: https:/ / norseev. ru/ 2018/ 01/ 04/ comportlist_windows/ нашёл схожую тему. Там приведён код на С++, который показывает только имена СОМ портов, типа,. . .
Сколько Государство потратило денег на меня, обеспечивая инсулином.
Programma_Boinc 20.11.2025
Сколько Государство потратило денег на меня, обеспечивая инсулином. Вот решила сделать интересный приблизительный подсчет, сколько государство потратило на меня денег на покупку инсулинов. . . .
Ломающие изменения в C#.NStar Alpha
Etyuhibosecyu 20.11.2025
Уже можно не только тестировать, но и пользоваться C#. NStar - писать оконные приложения, содержащие надписи, кнопки, текстовые поля и даже изображения, например, моя игра "Три в ряд" написана на этом. . .
Мысли в слух
kumehtar 18.11.2025
Кстати, совсем недавно имел разговор на тему медитаций с людьми. И обнаружил, что они вообще не понимают что такое медитация и зачем она нужна. Самые базовые вещи. Для них это - когда просто люди. . .
Создание Single Page Application на фреймах
krapotkin 16.11.2025
Статья исключительно для начинающих. Подходы оригинальностью не блещут. В век Веб все очень привыкли к дизайну Single-Page-Application . Быстренько разберем подход "на фреймах". Мы делаем одну. . .
Фото: Daniel Greenwood
kumehtar 13.11.2025
Расскажи мне о Мире, бродяга
kumehtar 12.11.2025
— Расскажи мне о Мире, бродяга, Ты же видел моря и метели. Как сменялись короны и стяги, Как эпохи стрелою летели. - Этот мир — это крылья и горы, Снег и пламя, любовь и тревоги, И бескрайние. . .
КиберФорум - форум программистов, компьютерный форум, программирование
Powered by vBulletin
Copyright ©2000 - 2025, CyberForum.ru