Skip to content
This repository has been archived by the owner on Mar 3, 2023. It is now read-only.

in the C syntax, when using 'scanf', #25627

Open
iampruh887 opened this issue Sep 20, 2022 · 0 comments
Open

in the C syntax, when using 'scanf', #25627

iampruh887 opened this issue Sep 20, 2022 · 0 comments

Comments

@iampruh887
Copy link

Prerequisites

[X] Put an X between the brackets on this line if you have done all of the following:
* Reproduced the problem in Safe Mode: https://flight-manual.atom.io/hacking-atom/sections/debugging/#using-safe-mode
* Followed all applicable steps in the debugging guide: https://flight-manual.atom.io/hacking-atom/sections/debugging/
* Checked the FAQs on the message board for common solutions: https://discuss.atom.io/c/faq
* Checked that your issue isn't already filed: https://github.com/issues?utf8=✓&q=is%3Aissue+user%3Aatom
* Checked that there is not already an Atom package that provides the described functionality: https://atom.io/packages

Description

in the C syntax, when using _scanf_ , by default it gives the user this as the syntax:

scanf("%s\n", ); now everything seems to be ok, BUT, after %s the \n is the main problem as shown below

Steps to Reproduce

I have run the code in normal as well as safe mode.

  1. well after writing the boiler plate code for C,
#include <stdio.h>
int main(int argc, char const *argv[]) {
  /* code */
  return 0;
}
  1. and then int the main function after writing scanf and some additional printf statement,
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int a;
  printf("enter the number\n");
  scanf("%d\n", &a);
  printf("%d\n", a);
  return 0;
}
  1. the \n is the problem in the scanf the \n in the printf and everywhere else is just fine.
    Expected behavior:
    after writing the code, i expect something like this:
    image
    image

Actual behavior:
this is what actually happens: the scanf instead of progressing the code moves the cursor to the new line , demanding another value
image

image

Reproduces how often:
100%

Versions

i am running the latest version of linuxmint

Additional Information

it is fine on other text editors as the do not provide the extra \n with scanf, atom needs to change it .
I took me nearly an hour to figure this out after getting multiple errors.
Thankyou.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant