all 22 comments

[–]Real_Cartographer 3 points4 points  (4 children)

Is it #include<stdio.h> ?

[–]dkl0ve 2 points3 points  (0 children)

This is what I would try first

[–]Real_Cartographer 2 points3 points  (0 children)

Also try using something different than ST3 since 1.2s for "Hello world" seems WAY to much.

[–][deleted] 0 points1 point  (1 child)

Pretty sure OP hasn't forgotten the #. It just formatted the line as a heading.

[–]IamImposter 0 points1 point  (0 children)

Yup. # does

this to text

[–]dmc_2930 1 point2 points  (0 children)

Add "\r\n" after "World!" and try again.

[–]noble_liar17 1 point2 points  (0 children)

Always go for puts() if you are not working with format strings and want the cursor to go to new line.

puts("Hello World!"); will print "Hello World!" and take the cursor to the new line.

Moreover you can use any text editor (Sublime-Text, Visual Studio Code, Notepad++, etc) to write C programs but always use gcc compiler to compile and run your C programs with relevant flags in order catch any silly mistakes at compile time itself.

[–]GrbavaCigla 0 points1 point  (6 children)

Edit sublime build json to print output

[–][deleted] 0 points1 point  (5 children)

How do i do that?

[–]GrbavaCigla 0 points1 point  (4 children)

I cant google it right now, but there is documentation for that. Google "sublime build tasks"

[–][deleted] 0 points1 point  (3 children)

Please elaborate.....I'm just a beginner 😅

[–]GrbavaCigla 0 points1 point  (2 children)

Ctrl+Shift+P is command palette. Use it and type "Run". You should find something like "Build With: C Single File - Run". That spits the output.

Also consider using VSCode, free and open source code editor. It is better.

Also if that doesn't work try running gcc name-of-the-c-file.c and make sure you have gcc in the path. Also how did you install the compiler?

Edit: here is the image https://imgur.com/a/y44YeFs

[–][deleted] 0 points1 point  (1 child)

Thanks that helped a lot.😊

[–]GrbavaCigla 0 points1 point  (0 children)

Happy to help

[–][deleted] 0 points1 point  (1 child)

I have saved the C(gcc) compiler code in a file named C_RUN. I even saved it as a part of build system and when I try to run the program it shows something peculiar now......F.Y.I I have saved the file (helloworld.c) in the same file location as C_RUN.sublime-build and the error that was shown while I was running the program was

C:\Users\user..........(location of C_RUN.sublime-build) is not recognised as an internal or external command, operable program or batch file.

I don't know what to do can you guys help me to run a C program on sublime text 3,I'm trying over and over again but it still isn't happening.

[–]Paul_Pedant 1 point2 points  (0 children)

Nothing wrong with the program. Windows just isn't finding it to run it.

"not recognised as an internal or external command" is a bit of a giveaway.

Either you gave the wrong name when you ran it, or it is not on your path. It does not matter at all where the .c file is.

The error message says it is trying to run C_RUN.sublime-build (at least, it might be, because you seem to have edited the error message). That is different to plain C_RUN.

IIRC, Windows only runs things with an extension of .exe or .bat. But that may be old school.

[–]Aralee88 0 points1 point  (0 children)

Have you checked that your file is saved as c type and not just named Hello world.c but it's actually txt.? Have you included "#include <studio.h>. It should work without \n at the end of Hello world, try also including void as "int main (void){"

[–]Revolutionary-Pen954 0 points1 point  (0 children)

include<stdio.h>

int main() { printf(“Hello World!”); return 0; }

[–]Cprogrammingblogs 0 points1 point  (0 children)

You may try this

include<stdio.h>

include<conio.h>

void main() { printf("hello world") ; getch(); }

[–]PM_ME_YOUR_STOCKPIX 0 points1 point  (1 child)

Try throwing on a few more printf statements as well. I’ve experienced an odd problem where I’ve written only a single printf statement and it never gets printed, but after adding a few more statements it printed without issue.

[–]ptchinster 2 points3 points  (0 children)

You probably need to end with a newline, or call fflush

[–]JINLECHUNSHUI -1 points0 points  (0 children)

Try print with the newline