fork download
  1. #include <stdio.h>
  2. #include <stdlib.h> // Include <stdlib.h> for the use of `exit()`
  3.  
  4. int main(void) {
  5. int b;
  6. scanf("%d", &b);
  7. getchar(); // Consume the newline character left in the input buffer
  8.  
  9. char a[b+1]; // Allocate space for b characters plus the null terminator
  10. fgets(a, sizeof(a), stdin);
  11.  
  12. // Remove newline character if present
  13. for (int i = 0; i < b; i++) {
  14. if (a[i] == '\n') {
  15. a[i] = '\0'; // Replace newline character with null terminator
  16. break;
  17. }
  18. }
  19.  
  20. puts(a);
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 5300KB
stdin
40
hello i am aryan
stdout
hello i am aryan