コード例 #1
0
ファイル: main.c プロジェクト: eschmar/kth-is1200
/* This is the main function */
int main()
{
  /* Local variables. */
  int m;
  int * p; /* Declare p as pointer, so that p can hold an address. */
  char c[ 4 ] = "Hej"; 

  /* Do some calculation. */
  gv = 4;
  m = gv + in;

  /* Check the addresses and values of some variables and stuff */
  saveword( "AM1: gv", &gv );
  saveword( "AM2: in", &in );
  saveword( "AM3: fun", &fun );
  saveword( "AM4: main", &main );

  p = &m;

  /* Check p and m */
  saveword( "AM5: p", &p );
  saveword( "AM6: m", &m );

  /* Change *p */

  *p = *p + 1;

  /* Check p and m */
  saveword( "AM7: p", &p );
  saveword( "AM8: m", &m );

  p = (int*)c;   /* Casting a char pointer to a integer pointer */

  saveword( "AM9: p", &p );

  savebyte( "AM10: c[0]", &c[0] );
  savebyte( "AM11: c[1]", &c[1] );
  savebyte( "AM12: c[2]", &c[2] );
  savebyte( "AM13: c[3]", &c[3] );

  *p = 0x1234abcd; /* It starts to get interesting... */

  savebyte( "AM14: c[0]", &c[0] );
  savebyte( "AM15: c[1]", &c[1] );
  savebyte( "AM16: c[2]", &c[2] );
  savebyte( "AM17: c[3]", &c[3] );

  fun(m);

  /* Re-check the addresses and values of m and gv */
  saveword( "AM18: m", &m );
  saveword( "AM19: gv", &gv );

  showinfo();
}
コード例 #2
0
ファイル: MkII.c プロジェクト: jstanley0/astro-timer
void Save()
{
	savebyte(0, stime[0]);
	savebyte(1, stime[1]);
	savebyte(2, delay[0]);
	savebyte(3, delay[1]);
	savebyte(4, count);
	savebyte(5, mlu);
	savebyte(6, bright);
}
コード例 #3
0
ファイル: fixwhite.c プロジェクト: AhmadTux/freebsd
static void
savewhite(char c, bool leading)
{
	off_t ncolumn;

	switch (c) {
	case '\n':
		if (leading) {
			/* Remove empty lines before input. */
			queuelen = 0;
			column = 0;
		} else {
			/* Remove trailing whitespace. */
			while (peekbyte(1, ' ') || peekbyte(1, '\t'))
				queuelen--;
			/* Remove redundant empty lines. */
			if (peekbyte(2, '\n') && peekbyte(1, '\n'))
				return;
			savebyte('\n');
		}
		break;
	case ' ':
		savebyte(' ');
		break;
	case '\t':
		/* Convert preceeding spaces to tabs. */
		ncolumn = (column / 8 + 1) * 8;
		while (peekbyte(1, ' ')) {
			queuelen--;
			column--;
		}
		while (column < ncolumn)
			savebyte('\t');
		break;
	}
}