compiling with gcc

compiling with gcc

offline
  • Pridružio: 30 Sep 2006
  • Poruke: 137

what command should i use if i want to compile a C code?

i use gcc test.c -o test if the program have jsut something to print, but what should i use if i need something to input from the keyboard?



Registruj se da bi učestvovao u diskusiji. Registrovanim korisnicima se NE prikazuju reklame unutar poruka.
offline
  • bocke  Male
  • Moderator foruma
  • Glavni moderator Linux foruma
  • Veliki Pingvin
  • Guru
  • Pridružio: 16 Dec 2005
  • Poruke: 12567
  • Gde živiš: Južni pol

The same thing. But I would recommend using Makefiles. If you intend on writing complex programs of more then 1 source file, you should use Makefiles. So learning to write one would be a good practice. There are a number of online tutorial on writing makefiles for GNU make:

[Link mogu videti samo ulogovani korisnici]
[Link mogu videti samo ulogovani korisnici]
[Link mogu videti samo ulogovani korisnici]
[Link mogu videti samo ulogovani korisnici]

There is a good online book on using gcc here:
[Link mogu videti samo ulogovani korisnici]

Dopuna: 10 Sep 2007 22:29

I forgot an example (this time without using Makefile). Let's say we're writing small demo program that takes user input and after that prints it out on standard output:

user_input.c
#include <stdio.h> int main(int argc, char *argv[]) {     char *temp[1024];     /* Getting an input */     printf("Input something: ");     scanf("%s", temp);     /* Writing out the value we entered */    printf("You entered: %s", temp);    return 0; }

We would compile this using this command line:

gcc user_input.c -o user_input

This is a simple example without using Makefiles. When you get more accustomed with C, you should learn on using them.



Ko je trenutno na forumu
 

Ukupno su 2173 korisnika na forumu :: 51 registrovanih, 5 sakrivenih i 2117 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 20624 - dana 04 Apr 2026 04:18

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: Bane san, Baždaranac, bestguarder, Betty25, bigfoot, Botovac, bukefal, Citalac, cvrle312, Dare, Despot Đurađ, dule10savic, Dvojac005, Dzigy, Georgius, GT, iceburn, Ivoo, janezek67, jodzula, K2, kenny74, Krusarac, Leteća Krofna, ljubo70, mean_machine, Medojed, Mihajlo, Miler88, Milometer, Mldo, Moldovan, Mrav Obrad, mrgud2025, nikoladim, paja69, proka89, radza1, raster12, skok, Smiljkovich, Sone0883, starlights, tanakadzo, vaso1, Velibor Radoja, vidra1, VJ, Vlada1389, wizzardone, zombicar153