示例#1
0
文件: cli.c 项目: idaohang/gpsr-1
int main( int argc, char **argv )
{
	char file[MAX_FILENAME_LEN + 1];
	char *line, *prompt="> ";
	int i;

	if ( argc == 2 )
		ystrncpy( file, argv[1], MAX_FILENAME_LEN );
	else
		yerror( "missing filename\n" );

	restores( file );
	prints();
	restorer( file );

	for( i = 0; i < status.datan; i++ )
		readdata( status.dataf[i], i );

	port = gp_open( "400x400" );
	using_history();
	stifle_history(1000);
	sprintf( historyfile, "%s/%s", getenv("HOME"), HISTORYFILE );
	if ( !access (historyfile, R_OK) )
		if ( read_history(historyfile) )
			perror( "reading history" );
	while (1) {
		line=readline( prompt );
		if ( line ) {
			add_history( line );
			parser( line );

		} else printf( "\n" );
	}
	return 0;
}
示例#2
0
int main()
{
    char src[81];
    char dst[81];
    char ch;
    int size;
    int i = 0;

    printf("Enter a string: \n");
    while ((ch = getchar()) != '\n')
    {
        src[i] = ch;
        i++;
    }
    src[i] = '\0';

    printf("Size lime: \n");
    scanf("%d", &size);

    ystrncpy(dst, src, size);
    printf("The copied string: %s\n", dst);

    return 0;
}