File: hello.c

package info (click to toggle)
mk-configure 0.37.0-2
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 4,112 kB
  • sloc: ansic: 5,441; makefile: 1,412; sh: 1,086; cpp: 200; perl: 101; yacc: 85; lex: 21
file content (30 lines) | stat: -rw-r--r-- 597 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

#ifndef HAVE_FUNC3_STRLCPY_STRING_H
size_t strlcpy(char *dst, const char *src, size_t siz);
#endif

#ifndef HAVE_FUNC3_GETLINE_STDIO_H
ssize_t getline(char** lineptr, size_t* n, FILE* stream);
#endif

int main (int argc, char ** argv)
{
	char *buf = NULL;
	size_t size = 0;
	ssize_t len = 0;
	char small_buf [10];

	while (len = getline (&buf, &size, stdin), len != -1){
		len = strlen (buf);
		if (len > 0 && buf [len-1] == '\n')
			buf [len-1] = 0;

		strlcpy (small_buf, buf, sizeof (small_buf));
		puts (small_buf);
	}

	return 0;
}