H C
17:
/ :
! "
# $ !
A.
1.
2.
3.
1. main
2.
3. ! "
4. # / $
1. # $
2. #
B. #
! "#$ # % & '&# ( )#$* +
A.
1.
,! "#$ # % & '&# ( )#$* +
%% % % .
& % ' ! %!
(DOS)
(
! ( $ !
A.
2.
-! "#$ # % & '&# ( )#$* +
) % « » ($ %% :
) ( “Windows” * , Microsoft
+ $ %% % ! MAC OS, UNIX,
LINUX * .
, « » Windows DOS, ( $ $ ) *
%( % :
- %! “dir” * . $ ($ % .
- %! “cls” * $ .
- %! “cd” %% . ($ %
/ 0 ( .
Windows ( %( ( % (
! DOS) ( .
A.
2.
.! "#$ # % & '&# ( )#$* +
, « => ! %1 » (start=>command prompt)
( %( DOS.
* $ % ! :
A.
2.
/! "#$ # % & '&# ( )#$* +
1 %( ( * % :
A.
3. , ! %!
1. , main
! "#$ # % & '&# ( )#$* +
+ $ % ' ( %! !
%! ! :
, . ! %! 1 main:
2 %% % %! :
! % (+1) %
'% ! argc
($ ' % (
$ ( ( (argv[1],argv[2],…argv[argc-1])
- ' % argv[0] %( .
%! % $ .
main(int argc, char *argv[])
{
...
}
A.
3. , ! %!
1. , main
0! "#$ # % & '&# ( )#$* +
% % :
/ %( DEV-C++. & ! $ ! % !
/* argc_argv.c: programma epideiksis
lipsis orismatwn apo ti grammi entolis */
#include <stdio.h>
main(int argc, char *argv[])
{
printf("Plithos = %d",argc);
printf("nOrismata = %s kai %s",argv[1],argv[2]);
}
A.
3. , ! %!
1. , main
1! "#$ # % & '&# ( )#$* +
) % ! %! $ %% % ! #
($ $ ( !
)
A.
3. , ! %!
2. # * %!
2! "#$ # % & '&# ( )#$* +
) % $ ! %!
% $ :
# ' . * %! ! %! !
/* argc_argv_loop.c Epideikniei tin xrisi
orismatwn grammis entolis */
#include <stdio.h>
main(int argc, char *argv[])
{
int i;
printf("argc=%d",argc);
for (i=0; i<argc; i++)
printf("nargv[%d]=%s",i,argv[i]);
}
A.
3. , ! %!
3. ! ' % %% (
! "#$ # % & '&# ( )#$* +
! ' % ( , % $ !
($
- ' % ( ( ( )
(* ( int.
To * $ ! atoi.
int atoi(char *s)
stdlib.h
A.
3. , ! %!
3. ! ' % %% (
! "#$ # % & '&# ( )#$* +
) $ ! atoi:
/* atoi.c: epideikniei tin sinartisi atoi */
#include <stdio.h>
main(int argc, char *argv[])
{
int x,y;
if(argc!=3)
{
printf("Prepei na eisagete 2 orismata!");
}
else
{
x=atoi(argv[1]);
y=atoi(argv[2]);
printf("nOrismata = %d kai %d",x,y);
}
}
A.
3. , ! %!
3. ! ' % %% (
,! "#$ # % & '&# ( )#$* +
$ . ! ( ' % %%
( :
" & !
int atoi(char *s) ( s int stdlib.h
long atol(char *s) ( s long stdlib.h
long long atoll(char *s) ( s long long stdlib.h
double atof(char *s)
( s double stdlib.h
A.
3. , ! %!
4. # $ ( ! ! ' %
-! "#$ # % & '&# ( )#$* +
$ . ! ( ' % %%
( :
, ! ( ($ ' % (
$ ( , %% :
( p (* % ' %
#.$. ' % ' % $ ! 0.54fd, strtod (0
0.54 p ' % «fd».
To base . ( s
( .$. ( 8- )
, 0.
" & !
double strtod( const char *s, char **p);
( s
double
stdlib.h
long strtol( const char *s, char **p,
int base );
( s
long
stdlib.h
unsigned long strtoul( const char *s,
char **p, int base );
( s
long long
stdlib.h
A.
4. -
1.
.! "#$ # % & '&# ( )#$* +
- $ %(
$ ( % !.
- ( %! % :
« » %( (% ( $
program > -
stdout
stdin
file
A.
4. -
1.
/! "#$ # % & '&# ( )#$* +
( % :
) ( $ 0!* 1 !
/* redirect_output.c: tha to xrisimopoiisoume
gia anakateuthinsi eksodou */
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
main()
{
int i;
srand(time(NULL));
for (i=0; i<20; i++)
printf("%dn",rand()%1000);
}
A.
4. -
1.
! "#$ # % & '&# ( )#$* +
/ ( % ! :
) ! ( :
redirect_output > file.txt
A.
4. -
1.
0! "#$ # % & '&# ( )#$* +
( ($ stdout $ ( file.txt
(To $ %( ( $ ( !)
.$. (% 1 :
A.
4. -
2.
1! "#$ # % & '&# ( )#$* +
- $ ' . ( stdin
%% .$. ( $ !
- ( %! % :
' . ( $ .
program < -
stdout
stdin
file
A.
4. -
2.
2! "#$ # % & '&# ( )#$* +
) % $ ( 20 :
/* redirect_input.c: tha to xrisimopoiisoume
gia anakateuthinsi eisodou */
#include <stdio.h>
#define N 20
main()
{
int i;
int array[N];
for (i=0; i<N; i++)
{
printf("Dwse ton epomeno arithmo: ");
scanf("%d", &array[i]);
}
printf("nPeriexomena Pinaka: ");
for (i=0; i<N; i++)
printf("%d ",array[i]);
}
A.
4. -
2.
! "#$ # % & '&# ( )#$* +
/ ( % ! :
) ! ! ( :
redirect_input < file.txt
A.
4. -
2.
! "#$ # % & '&# ( )#$* +
1 $ ( $ $ !:
:
1. - – ( % ! (Windows,
UNIX) .% . $ ( C
1. % ( %( !.
2. %( % 1 .
2. * % % ! %( $ . % %
,
• & ! $ ( ! ($ C
$ $ ( .$. fprintf fscanf) % !
3. !
* ! 1: $ ' % 1
,! "#$ # % & '&# ( )#$* +
0 ( :
1. & ' . ! %!
2. & ( ( ($
3. & $ ! insertion-sort
4. & 1 ( .
' $ :
1. ) ( argc-1
2. 4 ! % insertion-sort
« % C – 3: ) # »
3. $ % 1 ! .
3. !
* ! 2: / ! medium
-! "#$ # % & '&# ( )#$* +
# % * ! ( '%(0 « 3 » 1
0 ( ' . ( ! %! : ) ,
1 , % 0 ( ! ) :
1. & % . % ( $ 1 ( =1, B=2,
C=3 .% .))
2. & % . % ( )
3. & %% % . % 10
4. & %% % . 0 100
5. & . ( %(
- '%( ' (% :
• 1 300: & 1 «- %( : / »
• 301 600: & 1 «- %( : # % »
• 601 1000: & 1 «- %( : 1 / »
• 1000: & 1 «- %( : 1 %% 100 1», $
%( ( 1 ( 1000 1 % ! .

ΓΛΩΣΣΑ C - ΜΑΘΗΜΑ 17 - ΕΠΙΚΟΙΝΩΝΙΑ ΜΕ ΤΟ ΛΕΙΤΟΥΡΓΙΚΟ ΣΥΣΤΗΜΑ (ΕΚΤΥΠΩΣΗ)

  • 1.
    H C 17: / : !" # $ ! A. 1. 2. 3. 1. main 2. 3. ! " 4. # / $ 1. # $ 2. # B. # ! "#$ # % & '&# ( )#$* + A. 1. ,! "#$ # % & '&# ( )#$* + %% % % . & % ' ! %! (DOS) ( ! ( $ ! A. 2. -! "#$ # % & '&# ( )#$* + ) % « » ($ %% : ) ( “Windows” * , Microsoft + $ %% % ! MAC OS, UNIX, LINUX * . , « » Windows DOS, ( $ $ ) * %( % : - %! “dir” * . $ ($ % . - %! “cls” * $ . - %! “cd” %% . ($ % / 0 ( . Windows ( %( ( % ( ! DOS) ( .
  • 2.
    A. 2. .! "#$ #% & '&# ( )#$* + , « => ! %1 » (start=>command prompt) ( %( DOS. * $ % ! : A. 2. /! "#$ # % & '&# ( )#$* + 1 %( ( * % : A. 3. , ! %! 1. , main ! "#$ # % & '&# ( )#$* + + $ % ' ( %! ! %! ! : , . ! %! 1 main: 2 %% % %! : ! % (+1) % '% ! argc ($ ' % ( $ ( ( (argv[1],argv[2],…argv[argc-1]) - ' % argv[0] %( . %! % $ . main(int argc, char *argv[]) { ... } A. 3. , ! %! 1. , main 0! "#$ # % & '&# ( )#$* + % % : / %( DEV-C++. & ! $ ! % ! /* argc_argv.c: programma epideiksis lipsis orismatwn apo ti grammi entolis */ #include <stdio.h> main(int argc, char *argv[]) { printf("Plithos = %d",argc); printf("nOrismata = %s kai %s",argv[1],argv[2]); }
  • 3.
    A. 3. , !%! 1. , main 1! "#$ # % & '&# ( )#$* + ) % ! %! $ %% % ! # ($ $ ( ! ) A. 3. , ! %! 2. # * %! 2! "#$ # % & '&# ( )#$* + ) % $ ! %! % $ : # ' . * %! ! %! ! /* argc_argv_loop.c Epideikniei tin xrisi orismatwn grammis entolis */ #include <stdio.h> main(int argc, char *argv[]) { int i; printf("argc=%d",argc); for (i=0; i<argc; i++) printf("nargv[%d]=%s",i,argv[i]); } A. 3. , ! %! 3. ! ' % %% ( ! "#$ # % & '&# ( )#$* + ! ' % ( , % $ ! ($ - ' % ( ( ( ) (* ( int. To * $ ! atoi. int atoi(char *s) stdlib.h A. 3. , ! %! 3. ! ' % %% ( ! "#$ # % & '&# ( )#$* + ) $ ! atoi: /* atoi.c: epideikniei tin sinartisi atoi */ #include <stdio.h> main(int argc, char *argv[]) { int x,y; if(argc!=3) { printf("Prepei na eisagete 2 orismata!"); } else { x=atoi(argv[1]); y=atoi(argv[2]); printf("nOrismata = %d kai %d",x,y); } }
  • 4.
    A. 3. , !%! 3. ! ' % %% ( ,! "#$ # % & '&# ( )#$* + $ . ! ( ' % %% ( : " & ! int atoi(char *s) ( s int stdlib.h long atol(char *s) ( s long stdlib.h long long atoll(char *s) ( s long long stdlib.h double atof(char *s) ( s double stdlib.h A. 3. , ! %! 4. # $ ( ! ! ' % -! "#$ # % & '&# ( )#$* + $ . ! ( ' % %% ( : , ! ( ($ ' % ( $ ( , %% : ( p (* % ' % #.$. ' % ' % $ ! 0.54fd, strtod (0 0.54 p ' % «fd». To base . ( s ( .$. ( 8- ) , 0. " & ! double strtod( const char *s, char **p); ( s double stdlib.h long strtol( const char *s, char **p, int base ); ( s long stdlib.h unsigned long strtoul( const char *s, char **p, int base ); ( s long long stdlib.h A. 4. - 1. .! "#$ # % & '&# ( )#$* + - $ %( $ ( % !. - ( %! % : « » %( (% ( $ program > - stdout stdin file A. 4. - 1. /! "#$ # % & '&# ( )#$* + ( % : ) ( $ 0!* 1 ! /* redirect_output.c: tha to xrisimopoiisoume gia anakateuthinsi eksodou */ #include <stdio.h> #include <stdlib.h> #include <time.h> main() { int i; srand(time(NULL)); for (i=0; i<20; i++) printf("%dn",rand()%1000); }
  • 5.
    A. 4. - 1. ! "#$# % & '&# ( )#$* + / ( % ! : ) ! ( : redirect_output > file.txt A. 4. - 1. 0! "#$ # % & '&# ( )#$* + ( ($ stdout $ ( file.txt (To $ %( ( $ ( !) .$. (% 1 : A. 4. - 2. 1! "#$ # % & '&# ( )#$* + - $ ' . ( stdin %% .$. ( $ ! - ( %! % : ' . ( $ . program < - stdout stdin file A. 4. - 2. 2! "#$ # % & '&# ( )#$* + ) % $ ( 20 : /* redirect_input.c: tha to xrisimopoiisoume gia anakateuthinsi eisodou */ #include <stdio.h> #define N 20 main() { int i; int array[N]; for (i=0; i<N; i++) { printf("Dwse ton epomeno arithmo: "); scanf("%d", &array[i]); } printf("nPeriexomena Pinaka: "); for (i=0; i<N; i++) printf("%d ",array[i]); }
  • 6.
    A. 4. - 2. ! "#$# % & '&# ( )#$* + / ( % ! : ) ! ! ( : redirect_input < file.txt A. 4. - 2. ! "#$ # % & '&# ( )#$* + 1 $ ( $ $ !: : 1. - – ( % ! (Windows, UNIX) .% . $ ( C 1. % ( %( !. 2. %( % 1 . 2. * % % ! %( $ . % % , • & ! $ ( ! ($ C $ $ ( .$. fprintf fscanf) % ! 3. ! * ! 1: $ ' % 1 ,! "#$ # % & '&# ( )#$* + 0 ( : 1. & ' . ! %! 2. & ( ( ($ 3. & $ ! insertion-sort 4. & 1 ( . ' $ : 1. ) ( argc-1 2. 4 ! % insertion-sort « % C – 3: ) # » 3. $ % 1 ! . 3. ! * ! 2: / ! medium -! "#$ # % & '&# ( )#$* + # % * ! ( '%(0 « 3 » 1 0 ( ' . ( ! %! : ) , 1 , % 0 ( ! ) : 1. & % . % ( $ 1 ( =1, B=2, C=3 .% .)) 2. & % . % ( ) 3. & %% % . % 10 4. & %% % . 0 100 5. & . ( %( - '%( ' (% : • 1 300: & 1 «- %( : / » • 301 600: & 1 «- %( : # % » • 601 1000: & 1 «- %( : 1 / » • 1000: & 1 «- %( : 1 %% 100 1», $ %( ( 1 ( 1000 1 % ! .