English 中文(简体)
How can i Compile a C program on Dos prompt using tcc and tc
原标题:

I want to compile c program on dos prompt using tcc as well as tc without using c editor. please give the full procedure.

问题回答

I would look at the TCC documentation, specifically the quick start guide, provided on the TCC web page. Assuming you have some source code already, a compilation is as simple as

tcc -o executable.exe sourcefile.c

You can also run a C file directly with the -run option, as in

tcc -run sourcefile.c

you can run code without using an editor by using

tcc -run -

Using argument "-" will open stdin and you can write the code within stdin and execute it on the fly.

I m not sure if you mean Turbo C or Tiny C Compiler.

With Turbo C it can be as easy as:

tcc.exe myfile.c

This will produce myfile.exe if all the source code is in myfile.c.

If you run tcc.exe without parameters it will show what parameters it accepts.

There s documentation for Tiny C Compiler and it probably can show its usage too if run without parameters or with a specific parameter like -? or -help.

I try the two ways as follows. Both the first and the second are ok. But the thrid one could not work.

1. Run the script in the command line:

$ echo  main(){puts("Hello World");}  | tcc -run -
<stdin>:1: warning: implicit declaration of function  puts 
Hello World

2. Build hello.c and run with the command

1). Build hello.c

#!/usr/bin/tcc -run
#include <stdio.h>  

int main()
{
    printf("Hello World
");
}

2).call the application:

$ cd ./Documents/cfiles

$ tcc -run hello.c

Hello World

3. Run the lines one by one

I want to run codes one by one just like any Python script (>>>) on the Ubuntu Terminal, but it could not work.

$ tcc -run -

#include <stdio.h>

int main()
{
    printf("Hello, World!
");
    return 0;
}
main()




相关问题
Fastest method for running a binary search on a file in C?

For example, let s say I want to find a particular word or number in a file. The contents are in sorted order (obviously). Since I want to run a binary search on the file, it seems like a real waste ...

Print possible strings created from a Number

Given a 10 digit Telephone Number, we have to print all possible strings created from that. The mapping of the numbers is the one as exactly on a phone s keypad. i.e. for 1,0-> No Letter for 2->...

Tips for debugging a made-for-linux application on windows?

I m trying to find the source of a bug I have found in an open-source application. I have managed to get a build up and running on my Windows machine, but I m having trouble finding the spot in the ...

Trying to split by two delimiters and it doesn t work - C

I wrote below code to readin line by line from stdin ex. city=Boston;city=New York;city=Chicago and then split each line by ; delimiter and print each record. Then in yet another loop I try to ...

Good, free, easy-to-use C graphics libraries? [closed]

I was wondering if there were any good free graphics libraries for C that are easy to use? It s for plotting 2d and 3d graphs and then saving to a file. It s on a Linux system and there s no gnuplot ...

Encoding, decoding an integer to a char array

Please note that this is not homework and i did search before starting this new thread. I got Store an int in a char array? I was looking for an answer but didn t get any satisfactory answer in the ...

热门标签