← Back to team overview

sslug-teknik team mailing list archive

Re: Programmering under Linux!

 

On Tue, 29 Jun 1999, Dansbo, Jimmy wrote:

> Det jeg lige umiddelbart mangler er noget under Linux der minder om conio.h
> til Dos.

Hvad gør conio.h?

Anyway, under Linux, der slår du funktionerne op med "man". Så hvis du
f.eks. gerne vil bruge "printf", kan du skrive

man -k printf

På mit system giver det:

format (n)           - Format a string in the style of sprintf
gl_printf (3)        - write formatted output in graphic mode
printf (1)           - format and print data
printf, fprintf, sprintf, snprintf, vprintf, vfprintf, vsprintf, vsnprintf
(3) -
 formatted output conversion
printftest (6)       - tests the vgagl gl_printf function
snprintf, vsnprintf (3) - formatted output conversion

Der er altså flere forskellige printf. Tallene i () angiver "hylde"
nummeret på din kommando. Hylde 3 er normalt C (og andre sprog)
programmering, mens hylde 1 er shell programmering. Så for at se den
rigtige side, fyrer du en 

man 3 printf          

Her er toppen

PRINTF(3)           Linux Programmer's Manual           PRINTF(3)

NAME
       printf,  fprintf,  sprintf,  snprintf,  vprintf, vfprintf,
       vsprintf, vsnprintf - formatted output conversion

SYNOPSIS
       #include <stdio.h>

       int printf(const char *format, ...);
       int fprintf(FILE *stream, const char *format, ...);
       int sprintf(char *str, const char *format, ...);
       int snprintf(char *str, size_t size, const  char  *format,
       ...);


Så for at bruge printf, skal du altså inkludere <stdio.h>

Osv.

Mads

-- 
Mads Bondo Dydensborg.                               madsdyd@xxxxxxxxxxxx
Linux supports the notion of a command line or a shell for the same reason
that only children read books with only pictures in them. Language, be it
English or something else, is the only tool flexible enough to accomplish a
sufficiently broad range of tasks. 
                                     - Bill Garrett



References