依睛(IT blog) 我回来了,PHP<-->C/C++ LINUX

笨鸟

统计

积分与排名

友情连接

最新评论

英语关键词

http://www.google.cn/codesearch?hl=zh-CN&q=show:iS7xa4UiPco:PzESWualn3k:9OYPZZrZ7sw&sa=N&ct=rd&cs_p=http://ftp.gnu.org/gnu/glibc/glibc-2.3.3.tar.bz2&cs_f=glibc-2.3.3/stdio-common/bug12.c&start=1

top of stack 栈顶

#include <stdio.h>
int main()
{
 int lose = 1;

 /* Test  lose*/
 puts (lose ? "Test FAILED!" : "Test succeeded.");

 
 return 0;
}



===============================================
#include <stdio.h>

int
main (int arc, char *argv[])
{
  int n, res;
  unsigned int val;
  char s[] = "111";
  int result = 0;

  n = 0;
  res = sscanf(s, "%u %n", &val, &n);

  printf("Result of sscanf = %d\n", res);
  printf("Scanned format %%u = %u\n", val);
  printf("Possibly scanned format %%n = %d\n", n);
  result |= res != 1 || val != 111 || n != 3;


  result |= sscanf ("", " %n", &n) == EOF;

  puts (result ? "Test failed" : "All tests passed");

  return result;
}

==================================================

				
				
				#include <stdio.h>

				#include <stdlib.h>

				#include <string.h>

				
				
				int

				main (void)

				{

				  char *bp;

				  size_t size;

				  FILE *stream;

				  int lose = 0;

				
				
				  stream = open_memstream (&bp, &size);

				  fprintf (stream, "hello");

				  fflush (stream);

				  printf ("buf = %s, size = %Zu\n", bp, size);

				  lose |= size != 5;

				  lose |= strncmp (bp, "hello", size);

				  fprintf (stream, ", world");

				  fclose (stream);

				  printf ("buf = %s, size = %Zu\n", bp, size);

				  lose |= size != 12;

				  lose |= strncmp (bp, "hello, world", 12);

				
				
				  puts (lose ? "Test FAILED!" : "Test succeeded.");

				
				
				  free (bp);

				
				
				  return lose;

				}

		


=============================================

#include <stdio.h>
#include <string.h>
int
main (int argc, char *argv[])
{
  int ret;
  char buf [1024] = "Ooops";

  ret = sscanf ("static char Term_bits[] = {", "static char %s = {", buf);
  printf ("ret: %d, name: %s\n", ret, buf);

  return strcmp (buf, "Term_bits[]") != 0 || ret != 1;
}

===================================================

2
3
4
5
6
7
8
9
10
11
12
13
14
#include <stdio.h>
#include <string.h>
int
main (int argc, char *argv[])
{
  int ret;
  char buf [1024] = "Ooops";
  ret = sscanf ("static char Term_bits[] = {", "static char %s = {", buf);
  printf ("ret: %d, name: %s\n", ret, buf);
  return strcmp (buf, "Term_bits[]") != 0 || ret != 1;
}













				
				
				#include <stdio.h>

				#include <string.h>

				
				
				char x[4096], z[4096], b[21], m[4096 * 4];

				
				
				int

				main (void)

				{

				  FILE *f = tmpfile ();

				  int i, failed = 0;

				
				
				  memset (x, 'x', 4096);

				  memset (z, 'z', 4096);

				  b[20] = 0;

				
				
				  for (i = 0; i <= 5; i++)

				    {

				      fwrite (x, 4096, 1, f);

				      fwrite (z, 4096, 1, f);

				    }

				  rewind (f);

				
				
				  fread (m, 4096 * 4 - 10, 1, f);

				  fread (b, 20, 1, f);

				  printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx");

				  if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx"))

				    failed = 1;

				
				
				  fseek (f, -40, SEEK_CUR);

				  fread (b, 20, 1, f);

				  printf ("got %s (should be %s)\n", b, "zzzzzzzzzzzzzzzzzzzz");

				  if (strcmp (b, "zzzzzzzzzzzzzzzzzzzz"))

				    failed = 1;

				
				
				  fread (b, 20, 1, f);

				  printf ("got %s (should be %s)\n", b, "zzzzzzzzzzxxxxxxxxxx");

				  if (strcmp (b, "zzzzzzzzzzxxxxxxxxxx"))

				    failed = 1;

				
				
				  fread (b, 20, 1, f);

				  printf ("got %s (should be %s)\n", b, "xxxxxxxxxxxxxxxxxxxx");

				  if (strcmp (b, "xxxxxxxxxxxxxxxxxxxx"))

				    failed = 1;

				
				
				  return failed;

				}






































posted on 2008-01-19 20:15 向左向右走 阅读(420) 评论(0)  编辑 收藏 引用 所属分类: C/C++学习资料库大补英语

只有注册用户登录后才能发表评论。