A<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ru">
		<id>http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2FDevelopment%2FDebug</id>
		<title>C/Development/Debug - История изменений</title>
		<link rel="self" type="application/atom+xml" href="http://www.cppe.ru/index.php?action=history&amp;feed=atom&amp;title=C%2FDevelopment%2FDebug"/>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/Development/Debug&amp;action=history"/>
		<updated>2026-04-17T21:33:43Z</updated>
		<subtitle>История изменений этой страницы в вики</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C/Development/Debug&amp;diff=30&amp;oldid=prev</id>
		<title> в 14:20, 25 мая 2010</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/Development/Debug&amp;diff=30&amp;oldid=prev"/>
				<updated>2010-05-25T14:20:56Z</updated>
		
		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;tr style=&quot;vertical-align: top;&quot; lang=&quot;ru&quot;&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;← Предыдущая&lt;/td&gt;
				&lt;td colspan=&quot;1&quot; style=&quot;background-color: white; color:black; text-align: center;&quot;&gt;Версия 14:20, 25 мая 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; style=&quot;text-align: center;&quot; lang=&quot;ru&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(нет различий)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;&lt;/table&gt;</summary>
			</entry>

	<entry>
		<id>http://www.cppe.ru/index.php?title=C/Development/Debug&amp;diff=31&amp;oldid=prev</id>
		<title>Admin: 1 версия:&amp;#32;Импорт контента...</title>
		<link rel="alternate" type="text/html" href="http://www.cppe.ru/index.php?title=C/Development/Debug&amp;diff=31&amp;oldid=prev"/>
				<updated>2010-05-25T10:22:04Z</updated>
		
		<summary type="html">&lt;p&gt;1 версия: Импорт контента...&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Новая страница&lt;/b&gt;&lt;/p&gt;&lt;div&gt;==Copy a file in debug mode==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#define DEBUG&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
  FILE *from, *to;&lt;br /&gt;
  char ch;&lt;br /&gt;
  /* check number of command line arguments */&lt;br /&gt;
  if( argc != 3) {&lt;br /&gt;
    printf(&amp;quot;Usage: copy &amp;lt;source&amp;gt; &amp;lt;destination&amp;gt;\n&amp;quot;);&lt;br /&gt;
    exit(1);&lt;br /&gt;
  }&lt;br /&gt;
  /* open source file */&lt;br /&gt;
  if((from = fopen(argv[1], &amp;quot;rb&amp;quot;))==NULL) {&lt;br /&gt;
    printf(&amp;quot;Cannot open source file.\n&amp;quot;);&lt;br /&gt;
    exit(1);&lt;br /&gt;
  }&lt;br /&gt;
  /*open destination file */&lt;br /&gt;
  if((to = fopen (argv[2], &amp;quot;wb&amp;quot;)) ==NULL) {&lt;br /&gt;
    printf(&amp;quot;Cannot open destination file.\n&amp;quot;);&lt;br /&gt;
    exit(1);&lt;br /&gt;
  }&lt;br /&gt;
  while(!feof(from)) {&lt;br /&gt;
    ch = fgetc(from);&lt;br /&gt;
    if(ferror(from)) {&lt;br /&gt;
      printf(&amp;quot;Error reading source file.\n&amp;quot;);&lt;br /&gt;
      exit(1);&lt;br /&gt;
    }&lt;br /&gt;
    if(!feof(from)) {&lt;br /&gt;
      fputc(ch, to);&lt;br /&gt;
    }&lt;br /&gt;
    if(ferror(to)) {&lt;br /&gt;
      printf(&amp;quot;Error writing destination file.\n&amp;quot;);&lt;br /&gt;
      exit(1);&lt;br /&gt;
    }&lt;br /&gt;
  }&lt;br /&gt;
  fclose(from);&lt;br /&gt;
  fclose(to);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Copy a file in four debug level==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
/* DEBUG levels:&lt;br /&gt;
          0: no debug&lt;br /&gt;
          1: display byte read from source file&lt;br /&gt;
          2. display byte written to destination file&lt;br /&gt;
          3: display bytes read and bytes written&lt;br /&gt;
*/&lt;br /&gt;
#define DEBUG 2&lt;br /&gt;
int main(int argc, char *argv[])&lt;br /&gt;
{&lt;br /&gt;
  FILE *in, *out;&lt;br /&gt;
  unsigned char ch;&lt;br /&gt;
  /* see if correct number of command line arguments */&lt;br /&gt;
  if(argc!=4) {&lt;br /&gt;
    printf(&amp;quot;Usage: code &amp;lt;in&amp;gt; &amp;lt;out&amp;gt; &amp;lt;key&amp;gt;&amp;quot;);&lt;br /&gt;
    exit(1);&lt;br /&gt;
  }&lt;br /&gt;
  /* open input file */&lt;br /&gt;
  if((in = fopen(argv[1], &amp;quot;rb&amp;quot;))==NULL) {&lt;br /&gt;
    printf(&amp;quot;Cannot open input file.\n&amp;quot;);&lt;br /&gt;
    exit(1);&lt;br /&gt;
  }&lt;br /&gt;
  /* open output file */&lt;br /&gt;
  if((out = fopen(argv[2], &amp;quot;wb&amp;quot;))==NULL) {&lt;br /&gt;
    printf(&amp;quot;Cannot open output file.\n&amp;quot;);&lt;br /&gt;
    exit(1);&lt;br /&gt;
  }&lt;br /&gt;
  while(!feof(in)) {&lt;br /&gt;
    ch = fgetc(in);&lt;br /&gt;
#if DEBUG == 1 || DEBUG == 3&lt;br /&gt;
    putchar(ch);&lt;br /&gt;
#endif&lt;br /&gt;
    ch = *argv[3] ^ ch;&lt;br /&gt;
#if DEBUG &amp;gt;= 2&lt;br /&gt;
    putchar(ch);&lt;br /&gt;
#endif&lt;br /&gt;
    if(!feof(in)) fputc(ch, out);&lt;br /&gt;
  }&lt;br /&gt;
  fclose(in);&lt;br /&gt;
  fclose(out);&lt;br /&gt;
  return 0;&lt;br /&gt;
}&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Debugging using pre-processing directives==&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
   &lt;br /&gt;
&amp;lt;source lang=&amp;quot;cpp&amp;quot;&amp;gt;&lt;br /&gt;
#include &amp;lt;stdio.h&amp;gt;&lt;br /&gt;
#include &amp;lt;stdlib.h&amp;gt;&lt;br /&gt;
#define test&lt;br /&gt;
#define testf&lt;br /&gt;
int sum(int, int);&lt;br /&gt;
int product(int, int);&lt;br /&gt;
int difference(int, int);&lt;br /&gt;
int main()&lt;br /&gt;
{&lt;br /&gt;
  int i = 0;&lt;br /&gt;
  int j = 0;&lt;br /&gt;
  int a = 10, b = 5;&lt;br /&gt;
  int result = 0;&lt;br /&gt;
  int (*pfun[3])(int, int);&lt;br /&gt;
&lt;br /&gt;
  pfun[0] = sum;&lt;br /&gt;
  pfun[1] = product;&lt;br /&gt;
  pfun[2] = difference;&lt;br /&gt;
  for(i = 0 ; i &amp;lt; 3 ; i++)&lt;br /&gt;
  {&lt;br /&gt;
    j = i;&lt;br /&gt;
    #ifdef test&lt;br /&gt;
    printf(&amp;quot;\nRandom number = %d&amp;quot;, j );&lt;br /&gt;
    #endif&lt;br /&gt;
    result = pfun[j](a , b);&lt;br /&gt;
    printf(&amp;quot;\nresult = %d&amp;quot;, result );&lt;br /&gt;
  }&lt;br /&gt;
  result = pfun[1](pfun[0](a , b), pfun[2](a , b));&lt;br /&gt;
  printf(&amp;quot;\n\nThe product of the sum and the difference = %d\n&amp;quot;, result);&lt;br /&gt;
}&lt;br /&gt;
int sum(int x, int y){&lt;br /&gt;
  #ifdef testf&lt;br /&gt;
  printf(&amp;quot;\nFunction sum called.&amp;quot;);&lt;br /&gt;
  #endif&lt;br /&gt;
  return x + y;&lt;br /&gt;
}&lt;br /&gt;
int product( int x, int y ){&lt;br /&gt;
  #ifdef testf&lt;br /&gt;
  printf(&amp;quot;\nFunction product called.&amp;quot;);&lt;br /&gt;
  #endif&lt;br /&gt;
  return x * y;&lt;br /&gt;
}&lt;br /&gt;
int difference(int x, int y){&lt;br /&gt;
  #ifdef testf&lt;br /&gt;
  printf(&amp;quot;\nFunction difference called.&amp;quot;);&lt;br /&gt;
  #endif&lt;br /&gt;
  return x - y;&lt;br /&gt;
}&lt;br /&gt;
&lt;br /&gt;
           &lt;br /&gt;
       &amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Admin</name></author>	</entry>

	</feed>