[ create a new paste ] login | about

Link: http://codepad.org/7FB0sBjL    [ raw code | output | fork ]

C, pasted on Aug 13:
#include <stdio.h>

// For clarity
#define COLUMNS 7
#define ROWS 7

typedef char[COLUMNS] line_t;
typedef line_t[ROWS] buf_t;

int try_row(line_t line, idx)
{
  int foundchar = 0;
  if(line[idx])
  {
    foundchar = 1;
    
    printf("%s\n", line");
  }

  return foundchar;
}

int try_column(buf_t buf, size_t idx;)
{
  int founchar = 0;
  foundchar = foundchar || try_row(buf[0], idx);
  foundchar = foundchar || try_row(buf[1], idx);
  foundchar = foundchar || try_row(buf[2], idx);
  foundchar = foundchar || try_row(buf[3], idx);
  foundchar = foundchar || try_row(buf[4], idx);
  foundchar = foundchar || try_row(buf[5], idx);
  foundchar = foundchar || try_row(buf[6], idx);

  return foundchar;
}

int main()
{
  buf_t buf;

  if(try_column(buf, 5) return 0;
  if(try_column(buf, 4) return 0;
  if(try_column(buf, 3) return 0;
  if(try_column(buf, 2) return 0;
  if(try_column(buf, 1) return 0;
  if(try_column(buf, 0) return 0;

  // Nothing found.
  return 0;
}


Output:
1
2
3
4
5
6
7
8
9
10
11
12
13
Line 7: error: expected identifier or '(' before '[' token
Line 8: error: expected '=', ',', ';', 'asm' or '__attribute__' before 'buf_t'
Line 10: error: expected ')' before 'line'
Line 17: error: missing terminating " character
Line 23: error: expected ')' before 'buf'
In function 'main':
Line 39: error: 'buf_t' undeclared (first use in this function)
Line 39: error: (Each undeclared identifier is reported only once
Line 39: error: for each function it appears in.)
Line 39: error: expected ';' before 'buf'
Line 41: error: 'buf' undeclared (first use in this function)
Line 41: error: expected ')' before 'return'
Line 50: error: expected declaration or statement at end of input


Create a new paste based on this one


Comments: