[ create a new paste ] login | about

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

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

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


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

  return foundchar;
}

int try_column(char buf[COLUMNS][ROWS], size_t idx;)
{
  int foundchar = 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()
{
  char buf[7][7];
  memset(buf[0], 0, 7);
  memset(buf[1], 0, 7);
  memset(buf[2], 0, 7);
  memset(buf[3], 0, 7);
  memset(buf[4], 0, 7);
  memset(buf[5], 0, 7);
  memset(buf[6], 0, 7);

  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
In function 'try_column':
Line 25: error: 'buf' undeclared (first use in this function)
Line 25: error: (Each undeclared identifier is reported only once
Line 25: error: for each function it appears in.)
Line 25: error: 'idx' undeclared (first use in this function)


Create a new paste based on this one


Comments: