char char 1 signed char unsigned char ( ; single-quote 0x27) ASCII Japan Advanced Institute of Science and Technology

Similar documents
debug ( ) 1) ( ) 2) ( ) assert, printf ( ) Japan Advanced Institute of Science and Technology

: CR (0x0d) LF (0x0a) line separator CR Mac LF UNIX CR+LF MS-DOS WINDOWS Japan Advanced Institute of Science and Technology

file"a" file"b" fp = fopen("a", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose(fp); fp = fopen("b", "r"); while(fgets(line, BUFSIZ, fp)) {... fclose

I void* School of Information Science, Japan Advanced Institute of Science and Technology

r07.dvi

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() 2 double *a[ ]; double 1 malloc() dou

ohp07.dvi

1 1.1 C 2 1 double a[ ][ ]; 1 3x x3 ( ) malloc() malloc 2 #include <stdio.h> #include

I117 7 School of Information Science, Japan Advanced Institute of Science and Technology

£Ã¥×¥í¥°¥é¥ß¥ó¥°ÆþÌç (2018) - Â裵²ó ¨¡ À©¸æ¹½Â¤¡§¾ò·ïʬ´ô ¨¡

/* sansu1.c */ #include <stdio.h> main() { int a, b, c; /* a, b, c */ a = 200; b = 1300; /* a 200 */ /* b 200 */ c = a + b; /* a b c */ }

ex12.dvi

fl™‹ä1.eps


超初心者用

I httpd School of Information Science, Japan Advanced Institute of Science and Technology

Taro-ポインタ変数Ⅰ(公開版).j

Microsoft PowerPoint - 5Chap15.ppt

II ( ) prog8-1.c s1542h017%./prog8-1 1 => 35 Hiroshi 2 => 23 Koji 3 => 67 Satoshi 4 => 87 Junko 5 => 64 Ichiro 6 => 89 Mari 7 => 73 D

10

C B

第1回 プログラミング演習3 センサーアプリケーション

橡Pro PDF

joho07-1.ppt

Original : Hello World! (0x0xbfab85e0) Copy : Hello World! (0x0x804a050) fgets mstrcpy malloc mstrcpy (main ) mstrcpy malloc free fgets stream 1 ( \n

I ASCII ( ) NUL 16 DLE SP P p 1 SOH 17 DC1! 1 A Q a q STX 2 18 DC2 " 2 B R b

1-4 int a; std::cin >> a; std::cout << "a = " << a << std::endl; C++( 1-4 ) stdio.h iostream iostream.h C++ include.h 1-4 scanf() std::cin >>

新・明解C言語 実践編

untitled

mstrcpy char *mstrcpy(const char *src); mstrcpy malloc (main free ) stdio.h fgets char *fgets(char *s, int size, FILE *stream); s size ( )

子ども・子育て支援新制度 全国総合システム(仮称)に関するインターフェース仕様書 市町村・都道府県編(初版)

ohp03.dvi

解きながら学ぶC++入門編

Taro-リストⅢ(公開版).jtd

untitled

A/B (2018/10/19) Ver kurino/2018/soft/soft.html A/B


2004

BW BW

02: 変数と標準入出力

ex01.dvi

Microsoft Word - C.....u.K...doc

r03.dvi

新版明解C言語 実践編

PSCHG000.PS

1 ( )

文字数は1~6なので 同じ本数の枝を持つパスで生成される呪文の長さは最大で6 倍の差がある 例えば 上図のようなケースを考える 1サイクル終了した時点では スター節点のところに最強呪文として aaaaaac が求まる しかしながら サイクルを繰り返していくと やがてスター節点のところに aaaaaa

02: 変数と標準入出力

I J

/ SCHEDULE /06/07(Tue) / Basic of Programming /06/09(Thu) / Fundamental structures /06/14(Tue) / Memory Management /06/1

02: 変数と標準入出力

[1] #include<stdio.h> main() { printf("hello, world."); return 0; } (G1) int long int float ± ±

r08.dvi

untitled

II 3 yacc (2) 2005 : Yacc 0 ~nakai/ipp2 1 C main main 1 NULL NULL for 2 (a) Yacc 2 (b) 2 3 y

ohp08.dvi

Microsoft Word - Cプログラミング演習(10)

(300, 150) 120 getchar() HgBox(x, y, w, h) (x, y), w, h #include <stdio.h> #include <handy.h> int main(void) { int i; double w, h; } HgO

O(N) ( ) log 2 N

1 C STL(1) C C C libc C C C++ STL(Standard Template Library ) libc libc C++ C STL libc STL iostream Algorithm libc STL string vector l

Taro-リストⅠ(公開版).jtd


HRBusinessReview_vol5

all


+ +

double 2 std::cin, std::cout 1.2 C fopen() fclose() C++ std::fstream 1-3 #include <fstream> std::fstream fout; int a = 123; fout.open( "data.t

The shop for LOOK 2 2 Index

_CS4.indd

FREE



< A796BD8AD991E58A77976C2D8CBE8CEA C B B835E2E706466>

STSNJ NL

I. Backus-Naur BNF : N N 0 N N N N N N 0, 1 BNF N N 0 11 (parse tree) 11 (1) (2) (3) (4) II. 0(0 101)* (

1. 入力した文字列を得る 1.1. 関数 scanf() を使う まずは関数 scanf() を使ったプログラムを作ってみましょう 1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: #include<stdio.h> #define SIZE 128 main(

ex01.dvi

ポインタ変数

日本外傷歯学会認定医(平成24年11月30日付) H

RX ファミリ用 C/C++ コンパイラ V.1.00 Release 02 ご使用上のお願い RX ファミリ用 C/C++ コンパイラの使用上の注意事項 4 件を連絡します #pragma option 使用時の 1 または 2 バイトの整数型の関数戻り値に関する注意事項 (RXC#012) 共用

pptx

ohp11.dvi

r11.dvi


kiso2-09.key

橡matufw

財団法人母子健康協会第三十回シンポジウム

NewBead_no17_4c_pdf.indd

untitled

O


/* do-while */ #include <stdio.h> #include <math.h> int main(void) double val1, val2, arith_mean, geo_mean; printf( \n ); do printf( ); scanf( %lf, &v

:30 12:00 I. I VI II. III. IV. a d V. VI


untitled

2

3 3.1 LAN ISDN (IP) 2 TCP/UDP IP IP IP IP (Ethernet) Ethernet LAN TCP/UDP LAN Ethernet LAN 2: Ethernet ATM, FDDI, LAN IP IP IP 3 IP 2 IP IP IP IP IP 3

bitvisor-ipc v12b.key

C¥×¥í¥°¥é¥ß¥ó¥° ÆþÌç

18 C ( ) hello world.c 1 #include <stdio.h> 2 3 main() 4 { 5 printf("hello World\n"); 6 } [ ] [ ] #include <stdio.h> % cc hello_world.c %./a.o

Transcription:

I117 3 1 School of Information Science, Japan Advanced Institute of Science and Technology

char char 1 signed char -128 127 unsigned char 0 255 ( ; single-quote 0x27) ASCII Japan Advanced Institute of Science and Technology 2008 1-2 1

ASCII man ascii SP 0 9 A Z a z Oct(8 ) 040 060 071 101 132 141 172 Hex(16 ) 20 30 39 41 5A 61 7A Dec(10 ) 20 48 57 65 90 97 122 Japan Advanced Institute of Science and Technology 2008 1-2 2

C 0 \0 ( ; double-quote 0x22) char *x="abcdef"; strcpy(dst, "foo.tar.gz"); Japan Advanced Institute of Science and Technology 2008 1-2 3

char *x="abcde"; char y[]={ A, B, C, D, E, \0 }; 4bytes A B C 0x41 0x42 0x43 D E 0x44 0x45 \0 0x0 x 65 66 67 68 69 0 6bytes y 65 66 67 68 69 0 1byte Japan Advanced Institute of Science and Technology 2008 1-2 4

#include <stdio.h> char *x="abcde"; char *y="abcde"; int main() { printf("&x %p x %p size %d\n", &x, x, sizeof(x)); printf("&y %p y %p size %d\n", &y, y, sizeof(y)); } Japan Advanced Institute of Science and Technology 2008 1-2 5

(cont.) % cc ls3.c %./a.out &x 20dc8 x 20dd0 size 4 &y 20dcc y 20dd8 size 4 0x20dc8 0x20dd0 x 65 66 67 68 69 0 0x20dcc 0x20dd8 y 65 66 67 68 69 0 Japan Advanced Institute of Science and Technology 2008 1-2 6

% gcc ls3.c %./a.out &x 20940 x 10798 size 4 &y 20944 y 10798 size 4 0x20940 0x10798 x 65 66 67 68 69 0 0x20944 y Japan Advanced Institute of Science and Technology 2008 1-2 7

(cont.) Japan Advanced Institute of Science and Technology 2008 1-2 8

malloc, strdup strcpy, strcat strchr, strstr free Japan Advanced Institute of Science and Technology 2008 1-2 9

char *a = "Japan"; char *b, *c;... b = strdup("ishikawa"); c = (char*)malloc(9); c[0] = A ; c[1] = \0 ; Japan Advanced Institute of Science and Technology 2008 1-2 10

strdup strdup I s h i k a w a \0 duplicate b I s h i k a w a x = "Ishikawa"; b = malloc(strlen(x)+1); strcpy(b, x); \0 Japan Advanced Institute of Science and Technology 2008 1-2 11

strdup (cont.) char *x = "Ishikawa"; char *b = strdup(x); b[4] = y ; b[6] = m ; printf("x %p, %s\n", x, x); printf("b %p, %s\n", b, b); b x x 20dd0, Ishikawa b 20df8, Ishiyama Japan Advanced Institute of Science and Technology 2008 1-2 12

strdup (cont.) 0x20dd0 x I s h i k a w a \0 b 0x20df8 I s h i k a w a \0 y m x Japan Advanced Institute of Science and Technology 2008 1-2 13

char *p=src; while(*p) { p++; } p *p++ =? ; *p = \0 ; before src p middle src p after src p J A I S T \0 J A I S T \0 J A I S T? \0 Japan Advanced Institute of Science and Technology 2008 1-2 14

(cont.) strcat strcat(src,"?"); strcpy strcpy(src,"aist?"); => "AIST?" => "AIST?" strncpy \0 strncpy(src,"aist?", 2); => "AIIST" Japan Advanced Institute of Science and Technology 2008 1-2 15

(cont.) J A I S T + A I A I I S T memcpy, memmove Japan Advanced Institute of Science and Technology 2008 1-2 16

(cont.) src char *src=strdup("jaist"); strdup() char buf[10]; char *src=buf; 9 Japan Advanced Institute of Science and Technology 2008 1-2 17

char *p=src; char *q=null; while(*p) { q = p; p++; } q q NULL if(q) *q = # ; before src p after src p J A I S T \0 J A I S T \0 q q Japan Advanced Institute of Science and Technology 2008 1-2 18

(cont.) JAIS# int w;... w = strlen(src); if(w>0) { src[w-1] = # ; } Japan Advanced Institute of Science and Technology 2008 1-2 19

\0 char *a=(char*)malloc(10); a[0] = \0 ;... a[4] = \0 ; Japan Advanced Institute of Science and Technology 2008 1-2 20

1 char *p=src; char *x=null; while(*p) { if(*p== S ) { x = p; break; } p++; } x NULL Japan Advanced Institute of Science and Technology 2008 1-2 21

char *p=src; char *x=null; while(*p) { if(*p== A && *(p+1)== I ) { x = p; break; } p++; } x NULL Japan Advanced Institute of Science and Technology 2008 1-2 22

(cont.) strchr char *x = strchr("jaist", S ); strstr char *x = strstr("jaist", "AI"); Japan Advanced Institute of Science and Technology 2008 1-2 23

strdup(), malloc() free() Japan Advanced Institute of Science and Technology 2008 1-2 24

1) 3 asahidai dai main() int showlast3(char*); 2 Japan Advanced Institute of Science and Technology 2008 1-2 25

2) int showlastn(char*,int); Japan Advanced Institute of Science and Technology 2008 1-2 26