#include <stdio.h>
#include <stdlib.h>
#include <conio.h>
#include <windows.h>
void gotoxy(int x, int y)//x为列坐标,y为行坐标
{
COORD pos = {x,y};
HANDLE hOut = GetStdHandle(STD_OUTPUT_HANDLE);
SetConsoleCursorPosition(hOut, pos);
}
void str_in( char ch[], int m)//指定字符串及长度输入语句
{ char c;
int i,n;
for(i=0;i<m;i++)
{ n = -1;
do{
c=getch();
if( 1 ) n = c ;
}while( n<0 );
if( c == '\n' )break;
else {
ch[i]=c;
/*putchar('\b'); */
putchar(c);
};
};ch[i]=0;
}; void main()
{
char sc[9];
gotoxy(10,5);printf("请输入一个字符串c:");str_in(sc,8);
getch();
system("cls"); //清屏
gotoxy(11,5);printf("::::%s",sc);
} /*instr(char *pc,int m)
int c;
int n = -1;
do {
c = getch();
if( c == '\n' ) {
if( n != -1 )
break;
}
if( isdigit(c) ) {
putchar('\b');
putchar(c);
n = c - '0';
}
}while( 1 );
*/
联系客服