Advertisement
Riz1Ahmed

My Custom Sentence Input Function

Nov 23rd, 2018
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.22 KB | None | 0 0
  1. ///Fast Custom Sentence and Integer Input.
  2. #include<stdio.h>
  3. #include<string.h>
  4. void Sentance(char s[]){
  5.     char c; int i=0;
  6.     while((c=getchar())!='\n')
  7.         s[i++]=c;
  8.     s[i]='\0';
  9. }
  10.  
  11. int Read(ll &n){
  12.     int sign=1; c=getchar(),n=0;
  13.     for(; c<48 || 87<c; c=getchar())
  14.         if(c=='-') sign=-1;
  15.     for(; 47<c && c<58; c=getchar())
  16.         n=n*10+c-48;
  17.     n*=sign;
  18. }
  19.  
  20. int main(){
  21.     int n;
  22.     char s[1000];
  23.     Sentence(s), Read(n);
  24.     printf("%s %d\n",s,n);
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement