SSH Secure Shell 3.2.9 (Build 283)
Copyright (c) 2000-2003 SSH Communications Security Corp - http://www.ssh.com/
This copy of SSH Secure Shell is a non-commercial version.
This version does not include PKI and PKCS #11 functionality.
Last login: Sat Mar 24 11:29:17 2012 from 192.168.1.100
[root@lV root]# 出的/
-bash: 出的/: 没有那个文件或目录
[root@lV root]# cd /
[root@lV /]# cd test
[root@lV test]# vim 1-1.c
/*1-1.c 程序;在屏幕上输出“这是第一个linux才程序!*/
#include<stdio.h>
int main()
{
printf("这是第一个linux c 程序!\n");
return 0;
}
~
~
~
~
~
~
~
~
~
~
~
~
~
"1-1.c" [新] 7L, 137C 已写入
[root@lV test]# ls
1-1.c
[root@lV test]# gcc 1-1.c -o 1-1
[root@lV test]# ls
1-1 1-1.c
[root@lV test]# ./1-1
这是第一个linux c 程序!
[root@lV test]# alias
alias cp='cp -i'
alias l.='ls -d .* --color=tty'
alias ll='ls -l --color=tty'
alias ls='ls --color=tty'
alias mv='mv -i'
alias rm='rm -i'
alias vi='vim'
alias which='alias | /usr/bin/which --tty-only --read-alias --show-dot --show-tilde'
[root@lV test]# vi 1.1.1.c
#include<stdio.h>
int main()
{
printf("****\n");
printf("* *");
printf("* *");
printf("****");
return 0;
}
~
~
~
~
~
~
~
~
~
~
~
"1.1.1.c" [新] 9L, 119C 已写入
[root@lV test]# ls
1-1 1.1.1.c 1-1.c
[root@lV test]# gcc -o 1.1.1 1.1.1.c
[root@lV test]# ls
1-1 1.1.1 1.1.1.c 1-1.c
[root@lV test]# ./1.1.1
****
* ** *****[root@lV test]# vi 1.1.1.c
#include<stdio.h>
int main()
{
printf("****\n");
printf("* *\n");
printf("* *\n");
printf("****\n");
return 0;
}
~
~
~
~
~
~
~
~
~
~
~
"1.1.1.c" [已转换] 9L, 125C 已写入
[root@lV test]# ls
1-1 1.1.1 1.1.1.c 1-1.c
[root@lV test]# gcc -o 1.1.1 1.1.1.c
[root@lV test]# ./1.1.1
****
* *
* *
****
[root@lV test]# vi 1-2.c
/*1-2.c 程序:百分制换算成五级制*/
#include<stdio.h>
{
int score;
printf("请输入成绩:");
scanf("%d",&score);
if(score>=90)
printf("优秀\n");
else if(score>=80)
printf("良好\n");
else if(score>=70)
printf("中等\n");
else if(score>=60)
printf("及格\n");
else
printf("不及格\n");
return 0;
}
"1-2.c" [新] 22L, 361C 已写入
[root@lV test]# gcc 1-2.c -o 1-2
1-2.c:3: parse error before '{' token
1-2.c:5: parse error before string constant
1-2.c:5: warning: conflicting types for built-in function `printf'
1-2.c:5: warning: data definition has no type or storage class
1-2.c:6: parse error before string constant
1-2.c:6: warning: data definition has no type or storage class
[root@lV test]# vi 1-2.c
/*1-2.c 程序:百分制换算成五级制*/
#include<stdio.h>
int main()
{
int score;
printf("请输入成绩:");
scanf("%d",&score);
if(score>=90)
printf("优秀\n");
else if(score>=80)
printf("良好\n");
else if(score>=70)
printf("中等\n");
else if(score>=60)
printf("及格\n");
else
printf("不及格\n");
return 0;
}
"1-2.c" 23L, 372C 已写入
[root@lV test]# gcc 1-2.c -o 1-2
1-2.c:23: parse error before '}' token
[root@lV test]# cat -n 1-2.c
1 /*1-2.c 程序:百分制换算成五级制*/
2 #include<stdio.h>
3 int main()
4 {
5 int score;
6 printf("请输入成绩:");
7 scanf("%d",&score);
8 if(score>=90)
9 printf("优秀\n");
10 else if(score>=80)
11 printf("良好\n");
12 else if(score>=70)
13 printf("中等\n");
14 else if(score>=60)
15 printf("及格\n");
16 else
17 printf("不及格\n");
18 return 0;
19 }
20
21
22
23 }
[root@lV test]# vi 1-2.c
/*1-2.c 程序:百分制换算成五级制*/
#include<stdio.h>
int main()
{
int score;
printf("请输入成绩:");
scanf("%d",&score);
if(score>=90)
printf("优秀\n");
else if(score>=80)
printf("良好\n");
else if(score>=70)
printf("中等\n");
else if(score>=60)
printf("及格\n");
else
printf("不及格\n");
return 0;
}
~
"1-2.c" 22L, 370C 已写入
[root@lV test]# gcc 1-2.c -o 1-2
[root@lV test]# ./1-2
请输入成绩:80
良好
[root@lV test]# ./1-2
请输入成绩:100
优秀
[root@lV test]# ./1-2 20
请输入成绩:20
不及格
[root@lV test]# ./1-2 25.3
请输入成绩:25.3
不及格
[root@lV test]# ./1-2
请输入成绩:59.99999
不及格
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
}
~
~
~
~
~
~
~
"1.2.1.c" [新] 13L, 169C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
1.2.1.c: In function `main':
1.2.1.c:6: stray '\243' in program
1.2.1.c:6: stray '\254' in program
1.2.1.c:6: invalid operands to binary &
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\250' in program
1.2.1.c:7: parse error before "i"
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\251' in program
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
"1.2.1.c" 14L, 180C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
1.2.1.c: In function `main':
1.2.1.c:6: stray '\243' in program
1.2.1.c:6: stray '\254' in program
1.2.1.c:6: invalid operands to binary &
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\250' in program
1.2.1.c:7: parse error before "i"
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\251' in program
[root@lV test]# cat -n 1.2.1.c
1 #include<stdio.h>
2 int main()
3 {
4 float i;
5 printf("请输入一个数:\n");
6 scanf("%f",&i);
7 if(i>0)
8 printf("输入的为正数\n");
9 else
10 printf("输入的为非正数\n");
11 return 0;
12
13
14 }
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
?\<i\> 4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~ ~ ~ ~ ~ ~ 4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~ ~ ~ ~ ~ ~ 4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~ ~ ~ ~ ~ ~ 4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~ ~ ~ ~ ~ ~ 4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~ ~ ~ ~ ~ ~ 4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~ ~ ~ ~ ~ ~ 4,8-15 全部
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
"1.2.1.c" 14L, 180C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
1.2.1.c: In function `main':
1.2.1.c:6: stray '\243' in program
1.2.1.c:6: stray '\254' in program
1.2.1.c:6: invalid operands to binary &
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\250' in program
1.2.1.c:7: parse error before "i"
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\251' in program
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
"1.2.1.c" 14L, 179C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
1.2.1.c: In function `main':
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\250' in program
1.2.1.c:7: parse error before "i"
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\251' in program
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
"1.2.1.c" 14L, 179C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
1.2.1.c: In function `main':
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\250' in program
1.2.1.c:7: parse error before "i"
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\251' in program
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i; 1
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
"1.2.1.c" 14L, 183C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
1.2.1.c: In function `main':
1.2.1.c:5: parse error before "printf"
1.2.1.c:5: stray '\243' in program
1.2.1.c:5: stray '\251' in program
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\250' in program
1.2.1.c:7: parse error before "i"
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\251' in program
1.2.1.c:10: stray '\243' in program
1.2.1.c:10: stray '\251' in program
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i;
printf("请输入一个数:\n");
scanf("%f",&i);
if(i>0)
printf("输入的为正数\n");
else
printf("输入的为非正数\n");
return 0;
}
~
~
~
~
~
~
"1.2.1.c"
警告: 本文件自上次读入后已变动!!!
"1.2.1.c" 14L, 182C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
1.2.1.c: In function `main':
1.2.1.c:5: stray '\243' in program
1.2.1.c:5: stray '\251' in program
1.2.1.c:5: parse error before ';' token
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\250' in program
1.2.1.c:7: stray '\243' in program
1.2.1.c:7: stray '\251' in program
1.2.1.c:10: stray '\243' in program
1.2.1.c:10: stray '\251' in program
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i;
printf("input a number:\n");
scanf("%f",&i);
if(i>0)
printf("the numben is positive");
else
printf("the number is negative");
return 0;
}
~
~
~
~
~
~
"1.2.1.c" 14L, 193C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
[root@lV test]# ./1.2.1
input a number:
50
[root@lV test]# vi 1.2.1.c
#include<stdio.h>
int main()
{
float i;
printf("input a number:\n");
scanf("%f",&i);
if(i>0)
printf("the numben is positive\n");
else
printf("the number is negative\n");
return 0;
}
~
~
~
~
~
~
"1.2.1.c" [已转换] 14L, 197C 已写入
[root@lV test]# gcc 1.2.1.c -o 1.2.1
[root@lV test]# ./1.2.1
input a number:
90
the numben is positive
[root@lV test]# ./1.2.1
input a number:
0
the number is negative
[root@lV test]# ./1.2.1
input a number:
500
the numben is positive
[root@lV test]# vi1-3.c
-bash: vi1-3.c: command not found
[root@lV test]# vi 1-3.c
#include<stdio.h>
int main()
{
int a,b,sum;
printf("please input the first integer:\n");
scanf("%d",&a);
printf("please input the second integer:\n");
scanf("%d",&b);
sum=a+b;
printf("the sum is :%d\n",sum);
return 0;
}
~
~
~
~
~
~
~
"1-3.c" [新] 13L, 236C 已写入
[root@lV test]# gcc 1-3.c -o 1-3
[root@lV test]# ./1-3
please input the first integer:
20
please input the second integer:
50
the sum is :70
[root@lV test]# ./1-3
please input the first integer:
0
please input the second integer:
0
the sum is :0
[root@lV test]# gcc 1-3.c -o 1-3.i -E
[root@lV test]# ll
总用量 104
-rwxr-xr-x 1 root root 11556 3月 24 16:31 1-1
-rwxr-xr-x 1 root root 11590 3月 24 16:43 1.1.1
-rw-r--r-- 1 root root 125 3月 24 16:43 1.1.1.c
-rw-r--r-- 1 root root 137 3月 24 16:31 1-1.c
-rwxr-xr-x 1 root root 11797 3月 24 17:01 1-2
-rwxr-xr-x 1 root root 11759 3月 24 18:25 1.2.1
-rw-r--r-- 1 root root 197 3月 24 18:25 1.2.1.c
-rw-r--r-- 1 root root 204 3月 24 18:15 1.2.1.c~
-rw-r--r-- 1 root root 370 3月 24 17:01 1-2.c
-rwxr-xr-x 1 root root 11845 3月 24 18:33 1-3
-rw-r--r-- 1 root root 236 3月 24 18:33 1-3.c
-rw-r--r-- 1 root root 16654 3月 24 18:34 1-3.i
[root@lV test]# vi 1-3.i
# 1 "1-3.c"
# 1 "<built-in>"
# 1 "<command line>"
# 1 "1-3.c"
# 1 "/usr/include/stdio.h" 1 3
# 28 "/usr/include/stdio.h" 3
# 1 "/usr/include/features.h" 1 3
# 291 "/usr/include/features.h" 3
# 1 "/usr/include/sys/cdefs.h" 1 3
# 292 "/usr/include/features.h" 2 3
# 314 "/usr/include/features.h" 3
# 1 "/usr/include/gnu/stubs.h" 1 3
# 315 "/usr/include/features.h" 2 3
# 29 "/usr/include/stdio.h" 2 3
# 1 "/usr/lib/gcc-lib/i386-redhat-linux/3.2.2/include/stddef.h" 1 3
[root@lV test]# gcc 1-3.i -o 1-3.s -S
[root@lV test]# vi 1-3.s
.file "1-3.c"
.section .rodata
.align 32
.LC0:
.string "please input the first integer:\n"
.LC1:
.string "%d"
.align 32
.LC2:
.string "please input the second integer:\n"
.LC3:
.string "the sum is :%d\n"
.text
.globl main
.type main,@function
main:
pushl %ebp
movl %esp, %ebp
subl $24, %esp
andl $-16, %esp
[root@lV test]# gcc 1.3.s -o 1-3.o -c
gcc: 1.3.s: 没有那个文件或目录
gcc: no input files
[root@lV test]# gcc 1-3.s -o 1-3.o -c
[root@lV test]# vi 1-3.o
^?ELF^A^A^A^@^@^@^@^@^@^@^@^@^A^@^C^@^A^@^@^@^@^@^@^@^@^@^@^@╚A^@^@^@^@^@^@4^@^@^@^@^@(^@
^@^G^@U~I鍉C靆X~C漯竈@^@^@^@)膥C靆Lh^@^@^@^@椟~C腲P~C靆H~ME黀h!^@^@^@椟~C腲P~C靆Lh@^@^@^@椟~C腲P~C靆H~ME鳳h!^@^@^@椟~C腲P~KE鴁CE鼅IE魚C靆Hu鬶b^@^@^@椟~C腲P竈@^@^@^@擅^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@please input the first integer:
^@%d^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@^@please input the second integer:
^@the sum is :%d
@ @ @ @ @ @ @ @ @ @ @
[root@lV test]#
[root@lV test]#
[root@lV test]# vi 1-4.c
#include<stdio.h>
int main()
{
char ch;
while((ch=getchar())!=EOF)
putchar(ch);
return 1;
}
~
~
~
~
~
~
~
~
~
"1-4.c" [新] 11L, 100C 已写入
[root@lV test]# vi 1-4.c
#include<my.h>
int main()
{
char ch;
while((ch=getchar())!=EOF)
putchar(ch);
return 1;
}
~
~
~
~
~
~
~
~
~
"1-4.c" [已转换] 11L, 97C 已写入
[root@lV test]# cat 1-4.c
#include<my.h>
int main()
{
char ch;
while((ch=getchar())!=EOF)
putchar(ch);
return 1;
}
[root@lV test]# cd /root
[root@lV root]# vi my.h
#include<stdio.h>
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"my.h" [新] 1L, 18C 已写入
[root@lV root]# gcc 1-4.c -o 1-4
gcc: 1-4.c: 没有那个文件或目录
gcc: no input files
[root@lV root]# cd /test
[root@lV test]# gcc 1-4.c -o 1-4
1-4.c:1:15: my.h: 没有那个文件或目录
1-4.c: In function `main':
1-4.c:5: `EOF' undeclared (first use in this function)
1-4.c:5: (Each undeclared identifier is reported only once
1-4.c:5: for each function it appears in.)
[root@lV test]# mv /root/my.h /test
[root@lV test]# gcc 1-4.c -o 1-4
1-4.c:1:15: my.h: 没有那个文件或目录
1-4.c: In function `main':
1-4.c:5: `EOF' undeclared (first use in this function)
1-4.c:5: (Each undeclared identifier is reported only once
1-4.c:5: for each function it appears in.)
[root@lV test]#
[root@lV test]# vi my.h
#include<stdio.h>
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
[root@lV test]# vi1-4.c
-bash: vi1-4.c: command not found
[root@lV test]# vi 1-4.c
#include"my.h"
int main()
{
char ch;
while((ch=getchar())!=EOF)
putchar(ch);
return 1;
}
~
~
~
~
~
~
~
~
~
"1-4.c" [已转换] 11L, 97C 已写入
[root@lV test]# gcc 1-4.c -o 1-4
[root@lV test]# ./1-4
a
a
adffe
adffe
fefewfwefewfew
fefewfwefewfew
fefgwegffewfewfwefwefe
fefgwegffewfewfwefwefe
12fvvbfbgn
12fvvbfbgn
[root@lV test]# vi 1-4.c
#include<my.h>
int main()
{
char ch;
while((ch=getchar())!=EOF)
putchar(ch);
return 1;
}
~
~
~
~
~
~
~
~
~
"1-4.c" [已转换] 11L, 97C 已写入
[root@lV test]# gcc 1-4.c -o 1-4 -I /test
[root@lV test]# ./1-4
ughurghurhguirehguerihghire3423547^[[6~
ughurghurhguirehguerihghire3423547
[root@lV test]# vi 1-4.c
#include<my.h>
int main()
{
char ch;
while((ch=getchar())!=EOF)
putchar(ch);
return 0;
}
~
~
~
~
~
~
~
~
~
"1-4.c" [已转换] 11L, 97C 已写入
[root@lV test]# gcc 1-4.c -o 1-4 -I /test
[root@lV test]# ./1-4
efhef
efhef
fjiejfw
fjiejfw
fijeijfweof
fijeijfweof
eojfewf
eojfewf
fewfjwe
fewfjwe
abc
abc
[root@lV test]# vi 1-4.1.c
#include<stdio.h>
int main()
{
char ch[100];
scanf("&c",ch);
printf("&s\n",ch);
return 0;
}
~
~
~
~
~
~
~
~
~
~
~
"1-4.1.c" [新] 9L, 105C 已写入
[root@lV test]# gcc 1-4.1.c -o 1-4.1
[root@lV test]# ./1-4.1
fguefguefgue
&s
[root@lV test]# vi 1-4.1.c
#include<stdio.h>
int main()
{
char ch[100];
scanf("&c",ch);
printf("&c\n",ch);
return 0;
}
~
~
~
~
~
~
~
~
~
~
~
"1-4.1.c" [已转换] 9L, 105C 已写入
[root@lV test]# gcc 1-4.1.c -o 1-4.1
[root@lV test]# ./1-4.1
egfwfuiwefhuwief
&c
[root@lV test]# vi 1-4.1.c
#include<stdio.h>
int main()
{
char ch[100];
char * p;
scanf("&c",ch);
for(p=ch;*p!='\0';p++)
printf("&c",p);
printf("\n");
return 0;
}
~
~
~
~
~
~
~
"1-4.1.c" [已转换] 13L, 163C 已写入
[root@lV test]# gcc 1-4.1.c -o 1-4.1
[root@lV test]# ./1-4.1
fhuhfiweuhfiwe
&c&c&c&c&c&c&c&c&c&c&c&c&c&c&c&c&c&c
[root@lV test]# vi 1-4.1.c
#include<stdio.h>
int main()
{
char ch[100];
scanf("&s",ch);
printf("&s",ch);
return 0;
}
~
~
~
~
~
~
~
"1-4.1.c" [已转换] 13L, 119C 已写入
[root@lV test]# gcc 1-4.1.c -o 1-4.1
[root@lV test]# ./1-4.1
yghyrghre
[root@lV test]# vi 1-4.1.c.1
#include<stdio.h>
int main()
{
char ch[100];
scanf("%s",ch);
printf("%s",ch);
return 0;
}
~
~
~
~
~
~
~
"1-4.1.c" [已转换] 13L, 119C 已写入
[root@lV test]# gcc 1-4.1.c -o 1-4.1
[root@lV test]# ./1-4.1
hguhgur
[root@lV test]# vi 1-4.1.c
#include<stdio.h>
int main()
{
char ch[100];
scanf("%s",ch);
printf("%s",ch);
printf("\n");
return 0;
}
~
~
~
~
~
~
~
"1-4.1.c" [已转换] 13L, 133C 已写入
[root@lV test]# gcc 1-4.1.c -o 1-4.1
[root@lV test]# ./1-4.1
hello
hello
[root@lV test]# vi 1-6.c
#include<stdio.h>
#include<math.h>
int main()
{
double a,b;
printf("please input a numben as a X coordinate\n");
scanf("%lf",&a);
b=sin(a);
printf("sin(%lf)=%lf\n",a,b);
return 0;
}
~
~
~
~
~
~
~
"1-6.c" [新] 13L, 197C 已写入
[root@lV test]# gcc 1-6.c -o 1-6
/tmp/cc0WjlkV.o(.text+0x3e): In function `main':
: undefined reference to `sin'
collect2: ld returned 1 exit status
[root@lV test]# nm -o /lib/*.so|grep sin
nm: /lib/libacl.so: no symbols
/lib/ld-2.3.2.so:00015778 d _dl_sysinfo_int80
/lib/ld-2.3.2.so:00015354 d __libc_missing_32bit_uids
nm: /lib/libattr.so: no symbols
/lib/ld-2.3.2.so:00003710 t print_missing_version
/lib/libc-2.3.2.so:00116f80 t fde_single_encoding_compare
/lib/libc-2.3.2.so:00027730 t __GI___isinf
/lib/libc-2.3.2.so:00027aa0 t __GI___isinff
/lib/libc-2.3.2.so:00027ce0 t __GI___isinfl
/lib/libc-2.3.2.so:000e3200 t __GI_sysinfo
/lib/libc-2.3.2.so:0001b820 t internal_ascii_loop_single
/lib/libc-2.3.2.so:0001c990 t internal_ucs2_loop_single
/lib/libc-2.3.2.so:0001cf30 t internal_ucs2reverse_loop_single
/lib/libc-2.3.2.so:0001bc30 t internal_utf8_loop_single
/lib/libc-2.3.2.so:00027730 W isinf
/lib/libc-2.3.2.so:00027730 T __isinf
/lib/libc-2.3.2.so:00027aa0 W isinff
/lib/libc-2.3.2.so:00027aa0 T __isinff
/lib/libc-2.3.2.so:00027ce0 W isinfl
/lib/libc-2.3.2.so:00027ce0 T __isinfl
/lib/libc-2.3.2.so:001339f8 d __libc_missing_32bit_uids
/lib/libc-2.3.2.so:00080e30 W mbsinit
/lib/libc-2.3.2.so:00080e30 t __mbsinit
/lib/libc-2.3.2.so:000e3200 T sysinfo
/lib/libc-2.3.2.so:0001c660 t ucs2_internal_loop_single
/lib/libc-2.3.2.so:0001cc00 t ucs2reverse_internal_loop_single
/lib/libc-2.3.2.so:0013711c b using_malloc_checking
/lib/libc-2.3.2.so:0001c150 t utf8_internal_loop_single
nm: /lib/libcap.so: no symbols
/lib/libm-2.3.2.so:000088a0 W asin
/lib/libm-2.3.2.so:000088a0 t __asin
/lib/libm-2.3.2.so:0000fba0 W asinf
/lib/libm-2.3.2.so:0000fba0 t __asinf
/lib/libm-2.3.2.so:00007550 W asinh
/lib/libm-2.3.2.so:00007550 t __asinh
/lib/libm-2.3.2.so:0000eb40 W asinhf
/lib/libm-2.3.2.so:0000eb40 t __asinhf
/lib/libm-2.3.2.so:00015ce0 W asinhl
/lib/libm-2.3.2.so:00015ce0 t __asinhl
/lib/libm-2.3.2.so:00016f20 W asinl
/lib/libm-2.3.2.so:00016f20 t __asinl
/lib/libm-2.3.2.so:0000ab10 W casin
/lib/libm-2.3.2.so:0000ab10 t __casin
/lib/libm-2.3.2.so:00011ad0 W casinf
/lib/libm-2.3.2.so:00011ad0 t __casinf
/lib/libm-2.3.2.so:0000b3e0 W casinh
/lib/libm-2.3.2.so:0000b3e0 t __casinh
/lib/libm-2.3.2.so:000121e0 W casinhf
/lib/libm-2.3.2.so:000121e0 t __casinhf
/lib/libm-2.3.2.so:000199f0 W casinhl
/lib/libm-2.3.2.so:000199f0 t __casinhl
/lib/libm-2.3.2.so:00019120 W casinl
/lib/libm-2.3.2.so:00019120 t __casinl
/lib/libm-2.3.2.so:0000ada0 W csin
/lib/libm-2.3.2.so:0000ada0 t __csin
/lib/libm-2.3.2.so:00011ce0 W csinf
/lib/libm-2.3.2.so:00011ce0 t __csinf
/lib/libm-2.3.2.so:0000a3b0 W csinh
/lib/libm-2.3.2.so:0000a3b0 t __csinh
/lib/libm-2.3.2.so:00011430 W csinhf
/lib/libm-2.3.2.so:00011430 t __csinhf
/lib/libm-2.3.2.so:00018920 W csinhl
/lib/libm-2.3.2.so:00018920 t __csinhl
/lib/libm-2.3.2.so:000193a0 W csinl
/lib/libm-2.3.2.so:000193a0 t __csinl
/lib/libm-2.3.2.so:00000000 ? __evoke_link_warning___kernel_sinl
/lib/libm-2.3.2.so:0000c200 t __GI___isinf
/lib/libm-2.3.2.so:00012da0 t __GI___isinff
/lib/libm-2.3.2.so:0001a7c0 t __GI___isinfl
/lib/libm-2.3.2.so:00004f50 t __ieee754_asin
/lib/libm-2.3.2.so:0000c630 t __ieee754_asinf
/lib/libm-2.3.2.so:000130a0 t __ieee754_asinl
/lib/libm-2.3.2.so:000070b0 t __ieee754_sinh
/lib/libm-2.3.2.so:0000e510 t __ieee754_sinhf
/lib/libm-2.3.2.so:00015900 t __ieee754_sinhl
/lib/libm-2.3.2.so:0000c200 t isinf
/lib/libm-2.3.2.so:0000c200 t __isinf
/lib/libm-2.3.2.so:00012da0 t isinff
/lib/libm-2.3.2.so:00012da0 t __isinff
/lib/libm-2.3.2.so:0001a7c0 t isinfl
/lib/libm-2.3.2.so:0001a7c0 t __isinfl
/lib/libm-2.3.2.so:0000e830 t __kernel_sinf
/lib/libm-2.3.2.so:00015c20 t __kernel_sinl
/lib/libm-2.3.2.so:00008610 W sin
/lib/libm-2.3.2.so:00008610 t __sin
/lib/libm-2.3.2.so:0000a080 W sincos
/lib/libm-2.3.2.so:0000a080 t __sincos
/lib/libm-2.3.2.so:00011160 W sincosf
/lib/libm-2.3.2.so:00011160 t __sincosf
/lib/libm-2.3.2.so:000185f0 W sincosl
/lib/libm-2.3.2.so:000185f0 t __sincosl
/lib/libm-2.3.2.so:0000f930 W sinf
/lib/libm-2.3.2.so:0000f930 t __sinf
/lib/libm-2.3.2.so:00009b70 W sinh
/lib/libm-2.3.2.so:00009b70 t __sinh
/lib/libm-2.3.2.so:00010d20 W sinhf
/lib/libm-2.3.2.so:00010d20 t __sinhf
/lib/libm-2.3.2.so:00018090 W sinhl
/lib/libm-2.3.2.so:00018090 t __sinhl
/lib/libm-2.3.2.so:00016c70 W sinl
/lib/libm-2.3.2.so:00016c70 t __sinl
/lib/libm-2.3.2.so:00006b90 t sin_pi
/lib/libm-2.3.2.so:000153e0 t sin_pi
/lib/libm-2.3.2.so:0000dfa0 t sin_pif
nm: /lib/libnss_ldap-2.3.1.so: no symbols
nm: /lib/libnss_winbind.so: no symbols
nm: /lib/libnss_wins.so: no symbols
[root@lV test]# gcc 1-6.c -o 1-6 -lm
[root@lV test]# ./1-6
please input a numben as a X coordinate
30
sin(30.000000)=-0.988032
[root@lV test]# ./1-6
please input a numben as a X coordinate
0.5
sin(0.500000)=0.479426
[root@lV test]# vi 1-7.c
#include<stdio.h.>
int main()
{
long long tmp=1;
printf("this is a junky prom for testing !\n");
return 0;
}
~
~
~
~
~
~
~
~
~
~
~
~
~
"1-7.c" [新] 7L, 112C 已写入
[root@lV test]# gcc 1-7.c -o 1-7 -w
1-7.c:1:19: stdio.h.: 没有那个文件或目录
[root@lV test]# vi 1-7.c
#include<stdio.h>
int main()
{
long long tmp=1;
printf("this is a junky prom for testing !\n");
return 0;
}
~
~
~
~
~
~
~
~
~
~
~
~
~
"1-7.c" [已转换] 7L, 111C 已写入
[root@lV test]# gcc 1-7.c -o 1-7 -w
[root@lV test]# gcc 1-7.c -o 1-7 -ansi
[root@lV test]# gcc 1-7.c -o 1-7 -pedantic
1-7.c: In function `main':
1-7.c:4: warning: ISO C89 does not support `long long'
[root@lV test]# gcc 1-7.c -o 1-7 -Wall
1-7.c: In function `main':
1-7.c:4: warning: unused variable `tmp'
[root@lV test]# gcc 1-7.c -o 1-7 -Wall
1-7.c: In function `main':
1-7.c:4: warning: unused variable `tmp'
[root@lV test]# vi 1-8.c
#include<stdio.h>
int main(void )
{
double counter;
double result;
double temp;
for(counter=0;counter<40000.0*4000.0*4000.0/20.0+2030;
counter+=(5-3+2+1)/4 )
{
temp=counter/1239;
result=counter;
}
printf("the result is : %lf\n",result);
}
~
~
~
~
~
"1-8.c" [新] 15L, 260C 已写入
[root@lV test]# gcc 1-8.c -o 1-8
[root@lV test]# time ./1-8
real 0m52.894s
user 0m52.680s
sys 0m0.150s
[root@lV test]# gcc 1-8.c -o 1-8.0
[root@lV test]# gcc 1-8.c -o 1-8.2 -O2
[root@lV test]# ll
总用量 220
-rwxr-xr-x 1 root root 11556 3月 24 16:31 1-1
-rwxr-xr-x 1 root root 11590 3月 24 16:43 1.1.1
-rw-r--r-- 1 root root 125 3月 24 16:43 1.1.1.c
-rw-r--r-- 1 root root 137 3月 24 16:31 1-1.c
-rwxr-xr-x 1 root root 11797 3月 24 17:01 1-2
-rwxr-xr-x 1 root root 11759 3月 24 18:25 1.2.1
-rw-r--r-- 1 root root 197 3月 24 18:25 1.2.1.c
-rw-r--r-- 1 root root 204 3月 24 18:15 1.2.1.c~
-rw-r--r-- 1 root root 370 3月 24 17:01 1-2.c
-rwxr-xr-x 1 root root 11845 3月 24 18:33 1-3
-rw-r--r-- 1 root root 236 3月 24 18:33 1-3.c
-rw-r--r-- 1 root root 16654 3月 24 18:34 1-3.i
-rw-r--r-- 1 root root 1092 3月 24 18:38 1-3.o
-rw-r--r-- 1 root root 902 3月 24 18:36 1-3.s
-rwxr-xr-x 1 root root 11648 3月 24 18:59 1-4
-rwxr-xr-x 1 root root 11671 3月 24 19:24 1-4.1
-rw-r--r-- 1 root root 133 3月 24 19:24 1-4.1.c
-rw-r--r-- 1 root root 97 3月 24 18:59 1-4.c
-rwxr-xr-x 1 root root 11964 3月 24 19:40 1-6
-rw-r--r-- 1 root root 197 3月 24 19:35 1-6.c
-rwxr-xr-x 1 root root 11636 3月 24 19:51 1-7
-rw-r--r-- 1 root root 111 3月 24 19:49 1-7.c
-rwxr-xr-x 1 root root 11644 3月 24 19:59 1-8
-rwxr-xr-x 1 root root 11644 3月 24 20:00 1-8.0
-rwxr-xr-x 1 root root 11596 3月 24 20:01 1-8.2
-rw-r--r-- 1 root root 260 3月 24 19:59 1-8.c
-rw-r--r-- 1 root root 18 3月 24 18:51 my.h
[root@lV test]# touch result.txt
[root@lV test]# time ./1-8.0 >>result.txt
real 1m29.570s
user 1m28.940s
sys 0m0.390s
[root@lV test]# vi result.txt
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
~
"result.txt" [已转换] 0L, 0C 已写入
[root@lV test]# time ./1-8.2 >>result.txt
real 1m4.463s
user 1m4.330s
sys 0m0.130s
[root@lV test]# vi 1-9.c
#includese input the first integer");
#includ
#include<stdio.h>
int min(int x,int y);
int main()
{
int a1,a2,min_int;
printf("please input the first integer");
scanf("%d",&a1);
printf("please input the second integer");
scanf("%d",&a2);
min_int=min(a1,a2);
printf("the lower is :%d\n",min_int);
}
int min(int a,int y)
{
if(x<y)
return x;
else
return y;
}
"1-9.c" [新] 24L, 334C 已写入
[root@lV test]# gcc 1-9.c -o 1-9 -g
1-9.c: In function `min':
1-9.c:16: `x' undeclared (first use in this function)
1-9.c:16: (Each undeclared identifier is reported only once
1-9.c:16: for each function it appears in.)
[root@lV test]# vi 1-9.c
#include<stdio.h>
int min(int x,int y);
int main()
{
int a1,a2,min_int;
printf("please input the first integer");
scanf("%d",&a1);
printf("please input the second integer");
scanf("%d",&a2);
min_int=min(a1,a2);
printf("the lower is :%d\n",min_int);
}
int min(int x,int y)
{
if(x<y)
return x;
else
return y;
"1-9.c" [已转换] 24L, 334C 已写入
[root@lV test]# gcc 1-9.c -o 1-9 -g
[root@lV test]# gdb 1-9
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) l
1 #include<stdio.h>
2 int min(int x,int y);
3 int main()
4 {
5 int a1,a2,min_int;
6 printf("please input the first integer");
7 scanf("%d",&a1);
8 printf("please input the second integer");
9 scanf("%d",&a2);
10 min_int=min(a1,a2);
(gdb) l 15
10 min_int=min(a1,a2);
11 printf("the lower is :%d\n",min_int);
12
13 }
14 int min(int x,int y)
15 {
16 if(x<y)
17 return x;
18 else
19 return y;
(gdb) l11
Undefined command: "l11". Try "help".
(gdb) l 11
6 printf("please input the first integer");
7 scanf("%d",&a1);
8 printf("please input the second integer");
9 scanf("%d",&a2);
10 min_int=min(a1,a2);
11 printf("the lower is :%d\n",min_int);
12
13 }
14 int min(int x,int y)
15 {
(gdb) l 1
1 #include<stdio.h>
2 int min(int x,int y);
3 int main()
4 {
5 int a1,a2,min_int;
6 printf("please input the first integer");
7 scanf("%d",&a1);
8 printf("please input the second integer");
9 scanf("%d",&a2);
10 min_int=min(a1,a2);
(gdb) l 2
1 #include<stdio.h>
2 int min(int x,int y);
3 int main()
4 {
5 int a1,a2,min_int;
6 printf("please input the first integer");
7 scanf("%d",&a1);
8 printf("please input the second integer");
9 scanf("%d",&a2);
10 min_int=min(a1,a2);
(gdb) l8
Undefined command: "l8". Try "help".
(gdb) l 8
3 int main()
4 {
5 int a1,a2,min_int;
6 printf("please input the first integer");
7 scanf("%d",&a1);
8 printf("please input the second integer");
9 scanf("%d",&a2);
10 min_int=min(a1,a2);
11 printf("the lower is :%d\n",min_int);
12
(gdb) b 10
Breakpoint 1 at 0x80483b4: file 1-9.c, line 10.
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x080483b4 in main at 1-9.c:10
(gdb) r
Starting program: /test/1-9
please input the first integer20
please input the second integer50
Breakpoint 1, main () at 1-9.c:10
10 min_int=min(a1,a2);
(gdb) p a1
$1 = 20
(gdb) p a2
$2 = 50
(gdb) p min_int
$3 = 134513674
(gdb) p $1
$4 = 20
(gdb) p $2
$5 = 50
(gdb) s
min (x=20, y=50) at 1-9.c:16
16 if(x<y)
(gdb) s
17 return x;
(gdb) p x
$6 = 20
(gdb) s
23 }
(gdb) s
main () at 1-9.c:11
11 printf("the lower is :%d\n",min_int);
(gdb) p min_int
$7 = 20
(gdb) s
the lower is :20
13 }
(gdb) s
0x42015574 in __libc_start_main () from /lib/tls/libc.so.6
(gdb) s
Single stepping until exit from function __libc_start_main,
which has no line number information.
Program exited with code 021.
(gdb) r
Starting program: /test/1-9
please input the first integer20
please input the second integer2^H50
Breakpoint 1, main () at 1-9.c:10
10 min_int=min(a1,a2);
(gdb) p a1
$8 = 20
(gdb) set a1=70
(gdb) c
Continuing.
the lower is :2
Program exited with code 020.
(gdb) r
Starting program: /test/1-9
please input the first integer20
please input the second integer50
Breakpoint 1, main () at 1-9.c:10
10 min_int=min(a1,a2);
(gdb) b 9
Breakpoint 2 at 0x80483a0: file 1-9.c, line 9.
(gdb) info b
Num Type Disp Enb Address What
1 breakpoint keep y 0x080483b4 in main at 1-9.c:10
breakpoint already hit 1 time
2 breakpoint keep y 0x080483a0 in main at 1-9.c:9
(gdb) c
Continuing.
the lower is :20
Program exited with code 021.
(gdb) r
Starting program: /test/1-9
please input the first integer2^[[2~^H^H^H^H^H^H
Program received signal SIGINT, Interrupt.
0xffffe002 in ?? ()
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /test/1-9
please input the first integer20
Breakpoint 2, main () at 1-9.c:9
9 scanf("%d",&a2);
(gdb) p a2
$9 = 1108544020
(gdb) p a1
$10 = 20
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /test/1-9
please input the first integer20
Breakpoint 2, main () at 1-9.c:9
9 scanf("%d",&a2);
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) q
The program is running. Exit anyway? (y or n) n
Not confirmed.
(gdb) c
Continuing.
please input the second integer50
Breakpoint 1, main () at 1-9.c:10
10 min_int=min(a1,a2);
(gdb) set a1=100
(gdb) c
Continuing.
the lower is :50
Program exited with code 021.
(gdb) q
[root@lV test]# vi 1.c
#include<stdio.h>
int main()
{
printf("Linux 下的c也不是太难嘛!\n");
return 0;
}
~
~
~
~
~
~
~
~
~
~
~
~
~
"1.c" [新] 7L, 85C 已写入
[root@lV test]# gcc 1.c -o 1
[root@lV test]# ./1
Linux 下的c也不是太难嘛!
[root@lV test]# vi 2.c
#inc
#include
#include<stdio.h>
float avg(int x.int y);
int main()
{
int a1,a2;
float avg;
printf("please input the first integer:\n");
scanf("%d",&a1);
printf("please input the second integer:\n");
scanf("%d",&a2);
avg=avg(a1,a2);
printf("the avg is :%f\n",avg);
}
float avg(int x,int y)
{
return((x+y)/2.0)
}
"2.c" [新] 22L, 329C 已写入
[root@lV test]# gcc 2.c -o 2
2.c:2: parse error before '.' token
2.c: In function `main':
2.c:11: called object is not a function
2.c: In function `avg':
2.c:22: parse error before '}' token
[root@lV test]# vi 2.c
#include<stdio.h>
float avg(int x,int y);
int main()
{
int a1,a2;
float avg;
printf("please input the first integer:\n");
scanf("%d",&a1);
printf("please input the second integer:\n");
scanf("%d",&a2);
avg=avg(a1,a2);
printf("the avg is :%f\n",avg);
}
float avg(int x,int y)
{
return((x+y)/2.0);
"2.c" [已转换] 22L, 330C 已写入
[root@lV test]# gcc 2.c -o 2
2.c: In function `main':
2.c:11: called object is not a function
[root@lV test]# vi 2.c
#include<stdio.h>
float avgf(int x,int y);
int main()
{
int a1,a2;
float avgf;
printf("please input the first integer:\n");
scanf("%d",&a1);
printf("please input the second integer:\n");
scanf("%d",&a2);
avg=avgf(a1,a2);
printf("the avg is :%f\n",avg);
}
float avgf(int x,int y)
{
return((x+y)/2.0);
}
"2.c" [已转换] 22L, 334C 已写入
[root@lV test]# gcc 2.c -o 2
2.c: In function `main':
2.c:11: `avg' undeclared (first use in this function)
2.c:11: (Each undeclared identifier is reported only once
2.c:11: for each function it appears in.)
2.c:11: called object is not a function
[root@lV test]# vi 2.c
#include<stdio.h>
float avgf(int x,int y);
#include<stdio.h>
float avgf(int x,int y);
int main()
{
int a1,a2;
float avg;
printf("please input the first integer:\n");
scanf("%d",&a1);
printf("please input the second integer:\n");
scanf("%d",&a2);
avg=avgf(a1,a2);
printf("the avg is :%f\n",avg);
return 0;
}
float avgf(int x,int y)
{
return((x+y)/2.0);
"2.c" [已转换] 22L, 343C 已写入
[root@lV test]# gcc 2.c -o 2
[root@lV test]# ./2
please input the first integer:
20
please input the second integer:
21
the avg is :20.500000
[root@lV test]# gdb
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu".
(gdb) 2
Undefined command: "2". Try "help".
(gdb) ./2
Undefined command: "". Try "help".
(gdb) ./2
Undefined command: "". Try "help".
(gdb) 2
Undefined command: "2". Try "help".
(gdb) run 2
Starting program: 2
No executable file specified.
Use the "file" or "exec-file" command.
(gdb) q
[root@lV test]# gdb 2
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) l
1 ../sysdeps/i386/elf/start.S: 没有那个文件或目录.
in ../sysdeps/i386/elf/start.S
(gdb) l 1
1 in ../sysdeps/i386/elf/start.S
(gdb) list 5
1 in ../sysdeps/i386/elf/start.S
(gdb) q
[root@lV test]# gdb 2
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) r
Starting program: /test/2
please input the first integer:
20
please input the second integer:
50
the avg is :35.000000
Program exited normally.
(gdb) list 10
5 ../sysdeps/i386/elf/start.S: 没有那个文件或目录.
in ../sysdeps/i386/elf/start.S
(gdb) l
5 in ../sysdeps/i386/elf/start.S
(gdb) q
[root@lV test]# gcc 2.c -o 2 -g
[root@lV test]# gdb 2
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) s
The program is not being run.
(gdb) r
Starting program: /test/2
please input the first integer:
20
please input the second integer:
50
the avg is :35.000000
Program exited normally.
(gdb) l
1 #include<stdio.h>
2 float avgf(int x,int y);
3 int main()
4 {
5 int a1,a2;
6 float avg;
7 printf("please input the first integer:\n");
8 scanf("%d",&a1);
9 printf("please input the second integer:\n");
10 scanf("%d",&a2);
(gdb) l 10
5 int a1,a2;
6 float avg;
7 printf("please input the first integer:\n");
8 scanf("%d",&a1);
9 printf("please input the second integer:\n");
10 scanf("%d",&a2);
11 avg=avgf(a1,a2);
12 printf("the avg is :%f\n",avg);
13 return 0;
14
(gdb) b 10
Breakpoint 1 at 0x80483a0: file 2.c, line 10.
(gdb) r
Starting program: /test/2
please input the first integer:
20
please input the second integer:
Breakpoint 1, main () at 2.c:10
10 scanf("%d",&a2);
(gdb) s
Program received signal SIGINT, Interrupt.
0xffffe002 in ?? ()
(gdb) c
Continuing.
Program received signal SIGINT, Interrupt.
0xffffe002 in ?? ()
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /test/2
please input the first integer:
20
please input the second integer:
Breakpoint 1, main () at 2.c:10
10 scanf("%d",&a2);
(gdb) 50
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb)
Undefined command: "50". Try "help".
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /test/2
please input the first integer:
20
please input the second integer:
Breakpoint 1, main () at 2.c:10
10 scanf("%d",&a2);
(gdb) p a1
$1 = 20
(gdb) p a1 a2
A parse error in expression, near `a2'.
(gdb) pa2
Undefined command: "pa2". Try "help".
(gdb) p a2
$2 = 1108544020
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /test/2
please input the first integer:
20
please input the second integer:
Breakpoint 1, main () at 2.c:10
10 scanf("%d",&a2);
(gdb)
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n)
Please answer y or n.
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) q
The program is running. Exit anyway? (y or n) y
[root@lV test]# vi 4.c
#include<stdio.h>
int cube(int x);
int main()
{
int i;
for(i=100;i<999;i++)
{
if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
printf("%d\n",i);
}
return 0;
}
int cube (int x)
{
return(x*x*x);
}
~
"4.c" [新] 19L, 206C 已写入
[root@lV test]# gcc 4.c -o 4 -g
[root@lV test]# ./4
153
370
371
407
[root@lV test]# gdb 4
GNU gdb Red Hat Linux (5.3post-0.20021129.18rh)
Copyright 2003 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB. Type "show warranty" for details.
This GDB was configured as "i386-redhat-linux-gnu"...
(gdb) l
1 #include<stdio.h>
2 int cube(int x);
3 int main()
4 {
5 int i;
6 for(i=100;i<999;i++)
7 {
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
9 printf("%d\n",i);
10
(gdb) b 8
Breakpoint 1 at 0x804834e: file 4.c, line 8.
(gdb) l5
Undefined command: "l5". Try "help".
(gdb) l 5
1 #include<stdio.h>
2 int cube(int x);
3 int main()
4 {
5 int i;
6 for(i=100;i<999;i++)
7 {
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
9 printf("%d\n",i);
10
(gdb) l 10
5 int i;
6 for(i=100;i<999;i++)
7 {
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
9 printf("%d\n",i);
10
11
12 }
13 return 0;
14 }
(gdb) l 15
10
11
12 }
13 return 0;
14 }
15 int cube (int x)
16 {
17 return(x*x*x);
18
19 }
(gdb) b 17
Breakpoint 2 at 0x80483ff: file 4.c, line 17.
(gdb) r
Starting program: /test/4
Breakpoint 1, main () at 4.c:8
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
(gdb) p i
$1 = 100
(gdb) c
Continuing.
Breakpoint 2, cube (x=0) at 4.c:17
17 return(x*x*x);
(gdb) p x
$2 = 0
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /test/4
Breakpoint 1, main () at 4.c:8
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
(gdb) p i
$3 = 100
(gdb) c
Continuing.
Breakpoint 2, cube (x=0) at 4.c:17
17 return(x*x*x);
(gdb)
Continuing.
Breakpoint 2, cube (x=0) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 2, cube (x=1) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 1, main () at 4.c:8
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
(gdb) c
Continuing.
Breakpoint 2, cube (x=1) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 2, cube (x=0) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 2, cube (x=1) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 1, main () at 4.c:8
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
(gdb) c
Continuing.
Breakpoint 2, cube (x=2) at 4.c:17
17 return(x*x*x);
(gdb)
Continuing.
Breakpoint 2, cube (x=0) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 2, cube (x=1) at 4.c:17
17 return(x*x*x);
(gdb)
Continuing.
Breakpoint 1, main () at 4.c:8
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
(gdb) c
Continuing.
Breakpoint 2, cube (x=3) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 2, cube (x=0) at 4.c:17
17 return(x*x*x);
(gdb)
Continuing.
Breakpoint 2, cube (x=1) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 1, main () at 4.c:8
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
(gdb) c
Continuing.
Breakpoint 2, cube (x=4) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 2, cube (x=0) at 4.c:17
17 return(x*x*x);
(gdb)
Continuing.
Breakpoint 2, cube (x=1) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 1, main () at 4.c:8
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
(gdb) c
Continuing.
Breakpoint 2, cube (x=5) at 4.c:17
17 return(x*x*x);
(gdb) c
Continuing.
Breakpoint 2, cube (x=0) at 4.c:17
17 return(x*x*x);
(gdb)
Continuing.
Breakpoint 2, cube (x=1) at 4.c:17
17 return(x*x*x);
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n) y
Starting program: /test/4
Breakpoint 1, main () at 4.c:8
8 if(i==cube(i%10)+cube((i/10)%10)+cube(i/100))
(gdb) r
The program being debugged has been started already.
Start it from the beginning? (y or n)
Please answer y or n.
The program being debugged has been started already.
Start it from the beginning? (y or n)
Please answer y or n.
The program being debugged has been started already.
Start it from the beginning? (y or n) n
Program not restarted.
(gdb) q
The program is running. Exit anyway? (y or n) y
[root@lV test]#
[root@lV test]#
1 在代码中英文标点符号和非英文标点符号,真蛋疼
2 gdb调试的可执行程序 编译的时候 要带 -g 这个参数