anon20016

Перевод строки в число

Dec 12th, 2019
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4.  
  5. int main()
  6. {
  7.  
  8. // Перевод строки в число '1234'(char[]) = 1234(int)
  9. char c[100];
  10. gets(c);
  11. int result = 0;
  12. for (int i = 0; i < strlen(c); i++){
  13. result = result * 10 + (c[i] - '0');
  14. }
  15. printf("%i", result);
  16.  
  17. return 0;
  18. }
Add Comment
Please, Sign In to add comment