Задано текстовый файл. Определить номер заданного пользователем числа, если такого нет в строке, то сообщить об этом. "input.txt"= -5 1 9 7 -2 6 -1 0 2 3 -3 8 4 -4 -6 -8 -7 5 -9 10
Как это сделать?
#include <iostream>
#include <fstream>
using namespace std;
FILE *fin, *fout;
int main()
{
int p,n=0,count=0,r;
int arr[30];
fin = fopen("input.txt", "r");
fout = fopen("output.txt", "w");
cout << "Press number - ";
cin >> p;
ifstream fin("input.txt");
while (fin >> arr[n]) {
cout << arr[n]<<" ";
count++;
}
cout << endl;
for(int i=0;i<count;++i)
if (p = arr[n])
{
r = n;
}
cout << r;
cout << endl;
fprintf(fout, "Result: %i", r);
system("pause");
return 0;
}
if (p = arr[n])
,aif (p == arr[n])