extern - PowerPoint PPT Presentation

1 / 22
About This Presentation
Title:

extern

Description:

void printvals(int a, int b, int c, int x, int y, int z) ... ??????? : 0 strcmp('computer','babylon') 0 ,strcmp('abc','abcd') strcmp('Hi','Hi') == 0 ... – PowerPoint PPT presentation

Number of Views:84
Avg rating:3.0/5.0
Slides: 23
Provided by: Ofir
Category:
Tags: babylon | extern

less

Transcript and Presenter's Notes

Title: extern


1
???? ?????? (extern)
  • ?????? ???????? ?????? ??? ?????????, ????
    ???? ??? ?? ??? ????? ??????.
  • ?????? ???????? ???? ?????????. ???? ????
    (scope) ??? ????????? ??????? ??? ????? ?????
    ?????? ???????. ???? ???? ?? ??? ???? ??????.

2
???? ?????? (2)
  • ?????? ????????? ?????? ?? ????????, ????
    ???? ????? ??? ????????.
  • ?????? ??????? ?????? ????????? ?? ????????
    ???????? ??????? ??????? ?? ???? ????? ?"? ?????
    ????? ??????. ?? ???????? ???? ????? ????
    ???????? (??? ????? ??????) ???????? ?? ???
    ??????.
  • ??????? ?????? ???????? ?? ???????? ????????
    ????? ?????? ??? (???? ???????? ???? ??? ??
    ????????). ?? ????? ???????? ???????? ??? ???
    ?????? ?? ???? ???? ???????? ?"? ???? ??????
    ????????. ?? ???????? ????? ???? ?????? ????????
    ???????? ?? ??? ??????.

3
???? ?????? (3)
  • ?????? ?????? ???????? ?? ??? ??? ????? ??
    ????.
  • ????? ???????? ?????? ??????? ????????? ????
    ???? ???? ????? ?????? ????, ?? ???? ?? ?????
    ??????? ???? ?????? ???? ?????.
  • ????? ???? ??? ????? ????? ???? ??? ????
    ???????? ??? ?????, ????? ????? ??? ?? ??? ????
    ??????. ????? ?????? ???? ???? ??????? ????? ??
    ???? ?????? ?? ???? ????? ????????, ???? ??????
    ???? ????? ???????.

4
????? ?? ?????
  • include ltstdio.hgt
  • void printvals(int,int,int,int,int,int)
  • void oof(int,int,int)
  • int x5, y6, z7
  • int main()
  • int a 0
  • x 1 y 2 z 3
  • oof(7,8,9)
  • x
  • y
  • z
  • oof(x,y,z)
  • return 0

5
  • void oof(int a, int b, int c)
  • int x2
  • static int z 0
  • printvals(a,b,c,x,y,z)
  • x a
  • z x
  • y
  • int a
  • a x1
  • b y
  • c z
  • printvals(a,b,c,x,y,z)
  • printvals(a,b,c,x,y,z)

6
??????
  • ?????? ?? ?????? ??? ?????? ???? ?????? ?????
    ?????.
  • ??? ???? ?? ?? ????? ???? ??? ???? ?????.
  • ???? C ?????? ?????? ???? ?????, ?????, ??????
    ???'...

7
??????
  • ?????? ??????
  • ?? ??????? ????? ???? ???? ?????.
  • ??????? ???????? ????? ???? ??????? ?????.
  • ????? ?????? ????? ?????? ????? ???? 0 , ??????
    ?????? ????? ????? ???? 1.
  • (???? ????? ?????? ????? ???? ???? Arr ?"?
    ?????? Arr0 , ????? ???? ?"? Arr1 ???
    ????...).
  • ?? ????? ??? ????? ????? ????? .?? ?? ??? ????
    ????? ???? ??????.

8
?????? ????? ??????
  • ????? ????
  • lt?????gt lt?? ?????gt lt???? ??????gt
  • ??????
  • int Arr10
  • ????? ?? ???? 10 ?????? ?????? ??????, ????? ???
    Arr .
  • ?"? ????? ?? ????? ?? ?????? ?? ?????. ?? ??,
    ???? ????? ?????? ?? ? ????? ??????? ???? ??????
    ???????? - ??? !

???? ????? ????
9
?????? - ??????
  • ?? ????? ????? ???? ????? ???? ??????? ?????
  • int Arr10 1, 4, 6, 7, 8, 0 , 5, 5 , 1, 2
  • int Arr10 1,2,3
  • int Arr10 0
  • int Arr 1,2,3,4

??? ??????? ???????? ????
??? ?????? ????
?????? ???? ????? 4
10
??????
  • ?????? ??? ????? ?????? ????? ????? ?????
  • ????' ?????? ??????
  • int ArrSIZE ,I
  • for( i 0 i lt SIZE i)
  • Arri 0
  • ??????? ?????? ???????
  • int ArrSIZE ,i
  • for( i 0 i lt SIZE i)
  • if (scanf("d",Arri) lt 1)
  • printf(\nINPUT ERROR !)
  • return 1

11
????? ???? ?????? ????????
  • ???? ??????? ???? ???????? ?? ?????? ????, ?????,
    ????? ?????
  • ????? ????? ????? ???? ???????? ???? ?? ???? ??
    ???? ??
  • ????? ???????? ????
  • void f (int arr)
  • ??????? ?? ????? ??
  • f(arr) ( ?? arr0)

12
??????? Strings
  • ???? C ??? ????? ???? ??????
  • ?????? ???, ?????, ???? ?? ?????
  • ???? ?????? ???? ?? ????? \0 ????? ?-ascii
    ??? ??? ???.
  • ???? ???? ?????? ????? ?"? ?????? ?????? (????
    abc)
  • ???? ?? ????? ??? ???? ???? ?????? ????? ???? ??
  • ?? ????? ??? s ?-s ?

13
??????? Strings
  • ????? ?????? ???? ?????? ???? char str10
  • ?????? ?????? ???? ?????? ???? ?????? ????
    ??????
  • char str abc
  • char str a,b,c,\0
  • ???? ????? ?????? ??"? ?????? ???? ?????? ??????
    ??? str ?????? ??
  • ?? ???? ?? ????? ?? ??????? ?? char str10
    abc ?
  • ???? ????? ????? ???? ??????? ???? ??? ???????
    ????? ??? ????? ???? ???? ??? ?????? ?????
  • ?? ???? ?? ?????? ????? ??????? ?????? ???? ???
    (??? ????? ??????) ???? ????? ????? s (???? ???
    ????? ).
  • ?????, ?????? ?? ?? ????? ??????? ?????? ???

14
??????? Strings
  • ????? ?? ????? ?? ?????? ??????? ????? ????? ??
    ????? s
  • ????? ?????? ????? s ????? ?????? ?? ?? ??? ??
    ????? ???? ?????, ?????? ????? ??? \0
  • ????? ?????? ????? s ????? ?????? ?????? ?????
    ?? ??? \0(?? ????)

15
?????? ??? ?????? ????? ????
??? ?? ??????? ?
  • ???
  • char str10
  • scanf(s,str)
  • ???? ????? ???? ???? (???? ?? ??' ?????)?
  • int arr10
  • int i
  • for(i 0 i lt 10 i)
  • if ( scanf(d,arri) lt 1)
  • printf(input error !!\n)return 1

?????? ???? ?-scanf ????? ???? ????? ??????
?????? ?? ??? ????? ????? ?? ???? ?????. ????? ??
???? ?? ????? ??? ????? ??????
?? ????? ?????? ??? ?-scanf() !
16
?????? ??? ?????? ????? ????
  • ??????
  • ???? ????? ????? ?????? ??? ???? ????? ???? (????
    ???? int) ?
  • for (i0 iltn i)
  • arri
  • ????? ???? ?? ???? ??? ???? ???????
  • for (i0 stri ! \0 i)
  • stri
  • ???? ?? ??? ????? ?????? ???? ???? ?? ????
    ???????
  • ?? ?????? ????? ????? ???...

????? ?????? ???? ?? ???? ????? (n)
17
?????? ??? ?????? ????? ????
  • ??????? ????????
  • ??????? ??????? ???? ???? ???????? ????? ???? ???
    ????? ???? ????? ?? ?? ?????
  • int func(int arr, int n)
  • ??????? ?????? ???????? ?? ???? ????? ?????? ??
    ?? ?????, ???? ????? ???? ???? ??? ??? ???????
    ???? ?????? ????? ?????? ?? ?????
  • void func(char str)

18
?????? string.h
  • ?????? ????? ???? ?? ?? ???????? ????????
  • ?????? ???????? .
  • ????? ????? ?????? ???????? ??????? (???
    ??????( ?????? string.h
  • 1. int strcmp(const char s1,const char
    s2)
  • ???????? ????? ?? ??? ????????
    ???????????? ( ?? ???? ??? ???????
  • ?????? ??????) . ??????? ???? ???? ? 0
    ?? s1gts2 (????????????),
  • ???? ??? ? 0 ?? ,s1 lt s2? 0 ?? s1
    s2 .
  • ??????? 0 strcmp(computer,babylon) gt 0
    ,strcmp(abc,abcd) lt strcmp(Hi,Hi) 0


19
?????? string.h ????
  • .2 char strcpy(char s1,const char s2 )
  • ????? ?? ??????? s2 ???? ??????? s1 ????
    ???? \0 ???? ???????
  • ?? ?? ????? ? s1 ???? . ??????? ?? ?????? ?????
    ??? ????? ???? ? s1
  • ????? ?? ????? ?? ??????? s2 ???? ???? \0 .
    ?????? s1 ????? .
  • ??????? ??????
  • char s110 ,s2 Hello
  • strcpy(s1,s2)

  • / s1 Hello /
    printf(s,s1)
  • strcpy(s1,World)
  • / s1 World /
    printf(s,s1)


20
?????? string.h ????
  • size_t strlen(const char s) .3
  • ?????? ?? ????? ?? ??????? . ???? ???????
    ??? ???? ?????? ??????? ?? ???? ???? \0 .
  • ???????
  • strlen(1234) / 4 /
  • strlen(Example) / 7 /
  • ?????? ????? ?? ???????? ? string.h .

21
?????
  • ?????? ??? ????? ??????? ?????? ????? ??????? ???
    ????? ?????? ??????? ?? ??? (?????? ???????)
  • ??? ???? ?? ????? ?????? ????? ??? (???? a ,A
    ?????? ???? ??? )
  • ???? ?? ????? ??????? strings
  • ?? ???? ????
  • A appears 0 times in the string
  • B appears 0 times in the string
  • ...
  • G appears 1 times in the string
  • I appears 1 times in the string
  • ...
  • S appears 2 times in the string
  • ...

22
  • include ltstdio.hgt
  • define ABC 26
  • define SIZE 100
  • int main()
  • char sSIZE, ch
  • int aABC, i
  • printf("\nPlease enter the string\n")
  • if(scanf("s", s) ! 1)
  • printf("Input error\n")
  • return 1
  • for (i0 iltABC i) / initialization /
  • ai 0
  • i 0
Write a Comment
User Comments (0)
About PowerShow.com