Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void my_get_str (char *str, int lenght) {
- int i;
- char c;
- for (i=0; i<lenght-1 && (c=getchar()) != '\n' && c != EOF ; i++) {
- str[i] = c; }
- str[i] = '\0';
- if (c != '\n')
- {
- while((c = getchar())!= '\n');
- }
- }
- int my_get_int (int lenght){
- int i;
- char c;
- char* str = (char*)malloc(sizeof(char)*lenght);
- for (i=0; i<lenght-1 && (c=getchar()) != '\n' && c != EOF ; i++) {
- str[i] = c; }
- str[i] = '\0';
- if (c != '\n')
- {
- while((c = getchar())!= '\n');
- }
- return atoi(str);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement