D:\COURSE\OOP\ppnt>java lineno < lineno.java 1 //lineno.java --- by tsaiwn@csie.nctu.edu.tw 2 // javac lineno.java 3 // java lineno < file.name 4 // java lineno < file.name > file.txt 5 import java.io.*; 6 import java.util.*; 7 class lineno { 8 static PrintStream cout = System.out; 9 static BufferedReader br = new BufferedReader( 10 new InputStreamReader(System.in) ); 11 public static void main(String xxx[ ]) throws Exception { 12 String s; 13 int n = 0; 14 s = br.readLine( ); 15 while(s != null) { 16 //while( ! br.eof() ) { // C/C++ : feof(stdin) 17 ++n; 18 cout.printf("%5d %s\r\n", n, s); // for DOS/Windows 19 s = br.readLine( ); 20 } // while 21 cout.printf("\r\n"); // remove "\r" on Unix system 22 } // main 23 } D:\COURSE\OOP\ppnt>javac lineno.java D:\COURSE\OOP\ppnt>java lineno < yy.cpp 1 //yy.cpp -- see how compiler compile the program 2 //gcc -S yy.cpp 3 //more yy.s 4 void bar(double a, short b, long c){ } 5 void bar(double a, short b){short x[10]; x[0]=b;x[9]=(short)a;} 6 void bar(double a){ } 7 void bar(double *a){ } 8 void bar(double &a){ } 9 void bar(const double &a){ } 10 int aaa = 8; 11 int foo(int x, double y) { 12 static double aaa = y; 13 static short bbb=38; 14 int c= ::aaa; 15 bar(aaa, bbb, c); 16 } 17 int main( ) { 18 foo(1,2); 19 } D:\COURSE\OOP\ppnt>g++ -c yy.cpp // compile Only, 生出 yy.o (obj) D:\COURSE\OOP\ppnt>nm yy.o // nm 是 Unix 的基本指令 00000000 b .bss // Windows 在 Dec-C++ 的 bin 下有 nm.exe 00000000 d .data 00000000 r .rdata 00000000 t .text U ___main U __alloca 00000042 T __Z3bard ;; 這是 6 void bar(double a){ } 00000010 T __Z3bards ;; 這是 5 void bar(double a, short b){ .. 00000000 T __Z3bardsl ;; 這是4 void bar(double a,short b,long c){ } 00000048 T __Z3barPd ;; 這是 7 void bar(double *a){ } 0000004e T __Z3barRd ;; 這是 8 void bar(double &a){ } 00000054 T __Z3barRKd ;; 這是 9 void bar(const double &a){ } 0000005a T __Z3fooid ;; 這是 00000000 b __ZGVZ3fooidE3aaa ;; FLAG for static double aaa 設初值 00000000 D _aaa ;; 這是 10 int aaa = 8; 000000a4 T _main ;; 這是 17 int main( ) { 00000010 b _ZZ3fooidE3aaa ;; 這是 12 static double aaa = y; 00000004 d _ZZ3fooidE3bbb ;; 這是 13 static short bbb=38; D:\COURSE\OOP\ppnt>