Ошибка исполнения "Expression: stream != nullptr" - C (СИ)
Формулировка задачи:
Expression: stream != nullptr
For information on how your program can cause an assertion
failure, see the Visual C++ documentation on asserts.
# include <stdio.h>
# include <conio.h>
# include <stdlib.h>
# include <locale.h>
FILE *fp;
struct list1
{
char elem1;
list1 *next, *pred;
} *ph;
list1 *p, *H;
char sym;
struct list2
{
char elem2;
list2 *next;
};
list2 *search(list1 *ph, char sym2)
{
list2 *t, *R;
list1 *p = ph;
R = new list2;
R->next = NULL;
t = R;
do {
if (p->elem1 == sym2)
{
t->next = new list2;
t->next->next = new list2;
t = t->next;
t->elem2 = p->pred->elem1;
t = t->next;
t->next = NULL;
t->elem2 = p->next->elem1;
}
p = p->next;
} while (p != ph);
return R;
};
void main()
{
char c = 'c';
list2 *L, *lp = NULL;
setlocale(LC_CTYPE, "Rus");
{ ph = new list1;
ph->pred = NULL;
ph->next = NULL;
p = ph;
printf("Введите последовательность символов\n");
fscanf_s(fp, "%c", &sym);
while (sym != '.')
{
p->next = new list1;
p = p->next;
p->elem1 = sym;
fscanf_s(fp, "%c", &sym);
}
p->next = NULL;
p->pred = NULL;
}
printf("Введите символ \n");
scanf_s("%c", c);
L = search(H, c);
for (L = lp; lp != NULL; lp = lp->next);
fprintf(fp, "%c", lp->elem2);
_getch();
}Решение задачи: «Ошибка исполнения "Expression: stream != nullptr"»
textual
Листинг программы
L = search(H, c);