Главная страница
    Top.Mail.Ru    Яндекс.Метрика
Форум: "Начинающим";
Текущий архив: 2018.12.23;
Скачать: [xml.tar.bz2];

Вниз

чтение из файла и запись   Найти похожие ветки 

 
Arthur   (2016-09-29 02:55) [0]

unit Unit1;

interface

uses
 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
 Dialogs, StdCtrls;

type
 TForm1 = class(TForm)
   Button1: TButton;
   procedure Button1Click(Sender: TObject);
 private
   { Private declarations }
 public
   { Public declarations }
 end;

var
 Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var f,g:file of integer;
   x:array of array of integer;
   i,j,n,m,c:integer;
begin
 AssignFile(f,"myfile.txt");
 {$I-}
 Reset(f);
 {$I+};
 if IOResult<>0 then begin
   ShowMessage("файл не найден. прил-е закрыть"); Halt;
 end;
 n:=FileSize(f);
 m:=FileSize(f);
 if (n=0) and (m=0) then begin
   ShowMessage("файл пуст. прил-е закрыть"); CloseFile(f); Halt;
 end;
 AssignFile(g,"youfile.txt");
 Rewrite(g);
 SetLength(x,n,m);
 c:=0;
 for j:=0 to m-1 do
 begin
   for i:=0 to n-1 do
   Read(f,x[i,j]);
   begin
     if x[i,j] mod 2 = 1 then
     c:=c+1;
   end;
   Write(g,c);
   SetLength(x,0,0);
   CloseFile(f); CloseFile(g);
end;
end;

end.


 
Arthur   (2016-09-29 02:59) [1]

после запуска программы и нажатия кнопки выходит ошибка  
Project Project.exe raised exception class EAccessViolation with message "Access violation at address 0045275f in module "Project.exe". Read of address 00000026". Process stoped. use step or run to continue.


 
ВладОшин ©   (2016-09-29 07:58) [2]

дайте комментарии к вашему коду, где и что, по вашему мнению, делается
начиная с
n:=FileSize(f);
m:=FileSize(f);


 
iop ©   (2016-09-29 10:18) [3]

1. вложенный массив не инициализирован
2. x - это одномерный массив.  А это обращение к двумерному x[i,j]


 
Игорь Шевченко ©   (2016-09-29 10:20) [4]


> после запуска программы и нажатия кнопки выходит ошибка
>  
> Project Project.exe raised exception class EAccessViolation
> with message "Access violation at address 0045275f in module
> "Project.exe". Read of address 00000026". Process stoped.
>  use step or run to continue.


Запускай из-под отладчика.



Страницы: 1 вся ветка

Форум: "Начинающим";
Текущий архив: 2018.12.23;
Скачать: [xml.tar.bz2];

Наверх





Память: 0.45 MB
Время: 0.001 c
15-1475743983
KSergey
2016-10-06 11:53
2018.12.23
GitHub Desktop для WinXP


15-1476200879
Кто б сомневался
2016-10-11 18:47
2018.12.23
А есть расширения для хрома для проверки email?


15-1475245332
iop
2016-09-30 17:22
2018.12.23
задачка


4-1290160827
Boatswain
2010-11-19 13:00
2018.12.23
Кат узнать флэшка или кард-ридер


2-1475012292
Arthur
2016-09-28 00:38
2018.12.23
memo. запись в строку





Afrikaans Albanian Arabic Armenian Azerbaijani Basque Belarusian Bulgarian Catalan Chinese (Simplified) Chinese (Traditional) Croatian Czech Danish Dutch English Estonian Filipino Finnish French
Galician Georgian German Greek Haitian Creole Hebrew Hindi Hungarian Icelandic Indonesian Irish Italian Japanese Korean Latvian Lithuanian Macedonian Malay Maltese Norwegian
Persian Polish Portuguese Romanian Russian Serbian Slovak Slovenian Spanish Swahili Swedish Thai Turkish Ukrainian Urdu Vietnamese Welsh Yiddish Bengali Bosnian
Cebuano Esperanto Gujarati Hausa Hmong Igbo Javanese Kannada Khmer Lao Latin Maori Marathi Mongolian Nepali Punjabi Somali Tamil Telugu Yoruba
Zulu
Английский Французский Немецкий Итальянский Португальский Русский Испанский