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: 12544
  • 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 961 korisnika na forumu :: 62 registrovanih, 3 sakrivenih i 896 gosta   ::   [ Administrator ] [ Supermoderator ] [ Moderator ] :: Detaljnije

Najviše korisnika na forumu ikad bilo je 3466 - dana 01 Jun 2021 17:07

Korisnici koji su trenutno na forumu:
Korisnici trenutno na forumu: 357magnum, A.R.Chafee.Jr., Apok, Armadillo, Bane5, Belac91, Betta, black sabah, bladesu, Bojan198527, bokisha253, boxbole, bukefal, C-Gun, cikadeda, Denaya, desmeki, Djolek, EXIT78, Feller, havoc995, Iskander, JosipRi, Jozo74, Kajzer Soze, Kepinger, Krusarac, kunktator, kuntalo, Lucije Kvint, mat, Mercury, Metanoja, mexo, mikrimaus, miljevicz, Misterrno, mm1811, Motocar, Nemanja.M, nemkea71, nevjerna beba, Novakomp, opt1, Povratak1912, precan, redstar011, royst33, sap, Shadow soldier, superwhy, tubular, Tumansky, ujke, vazduh, VJ, voja64, yufighter, Zdilar, Zoran1959, zziko, 79693