Anshul Pratap Lakra
Anshul Pratap Lakra

Reputation: 1

Unable to take user Inputs in C language in Sublime Text

I want to take user inputs in c language but I am unable to as the Sublime Text does not allow that. I want to create a build system for C that will take user inputs and display output in the default window and not use the terminal or terminus. Can someone help me with this ?

I tried different build systems but that would work only if I ran Simple print programs but it wouldn't run when I tried to take user input.

Upvotes: 0

Views: 49

Answers (1)

khaos
khaos

Reputation: 11

  • Taking user inputs directly in Sublime Text's output window isn't supported by default because the output panel doesn't support interactive input.

  • However, since you want to avoid using those, you might consider an alternative approach.

You can create a new build system to prevent that:

  1. Go to: Tools > Build System > New Build System
  2. Change the default code with the following:

{

"cmd": ["gcc", "-o", "$file_base_name", "$file_name"],
"file_regex": "^(...*?):([0-9]*):?([0-9]*)",
"working_dir": "${file_path}",
"selector": "source.c",
"shell_cmd": "start cmd /c $file_base_name && pause"

}

  1. Donot forget to save

Now, whenever you press Ctrl + B, Sublime Text will compile your code and open an external command prompt to execute it, allowing for user input.

Upvotes: 1

Related Questions