变成可执行文件 总会提示有错误
- shenglongr
- 帖子: 143
- 注册时间: 2008-11-05 20:55
- 联系:
变成可执行文件 总会提示有错误
新手学习 遇到点问题 希望大家帮助 得到解决
ruanl@ruanl-desktop:~/cstudy$ gcc -Wall abfunction3.c
ruanl@ruanl-desktop:~/cstudy$ ./a.out
The result1 is 55.000000
The result2 is 225.000000ruanl@ruanl-desktop:~/cstudy$
这样子的话 没有提示错误 但接下来 这样 就
ruanl@ruanl-desktop:~/cstudy$ ./abfunction3.c
./abfunction3.c: line 2: int:找不到命令
./abfunction3.c: line 5: 在未预料的“(”附近出现语法错误
./abfunction3.c: line 5: ` double SumPower(int,int,int);'
1 #include<stdio.h>
2 int
3 main()
4 {
5 double SumPower(int,int,int);
6 double result1,result2;
7 result1=SumPower(1,5,2); /*在此处第一次调用SumPower函数*/
8 result2=SumPower(1,5,3); /*在此处第二次调用SumPower函数*/
9 printf("\nThe result1 is %lf",result1);
10 printf("\nThe result2 is %lf",result2);
11 return 0;
12 }
13
14 double SumPower(int lowLimit, int upLimit,int exp)
15 {
16 double Power(double,int);
17 double sum;
18 int counter;
19 sum=0;
20 for(counter=lowLimit;counter<=upLimit;counter++){
21 sum+=Power(counter,exp); /*在此处调用Power函数*/
22 }
23 return(sum);
24 }
25 double Power(double base,int exponent)
26 {
27 int counter;
28 double result;
29 result=1;
30 for(counter=1;counter<=exponent;counter++){
31 result*=base;
32 }
33 return(result);
34 }
35
ruanl@ruanl-desktop:~/cstudy$ gcc -Wall abfunction3.c
ruanl@ruanl-desktop:~/cstudy$ ./a.out
The result1 is 55.000000
The result2 is 225.000000ruanl@ruanl-desktop:~/cstudy$
这样子的话 没有提示错误 但接下来 这样 就
ruanl@ruanl-desktop:~/cstudy$ ./abfunction3.c
./abfunction3.c: line 2: int:找不到命令
./abfunction3.c: line 5: 在未预料的“(”附近出现语法错误
./abfunction3.c: line 5: ` double SumPower(int,int,int);'
1 #include<stdio.h>
2 int
3 main()
4 {
5 double SumPower(int,int,int);
6 double result1,result2;
7 result1=SumPower(1,5,2); /*在此处第一次调用SumPower函数*/
8 result2=SumPower(1,5,3); /*在此处第二次调用SumPower函数*/
9 printf("\nThe result1 is %lf",result1);
10 printf("\nThe result2 is %lf",result2);
11 return 0;
12 }
13
14 double SumPower(int lowLimit, int upLimit,int exp)
15 {
16 double Power(double,int);
17 double sum;
18 int counter;
19 sum=0;
20 for(counter=lowLimit;counter<=upLimit;counter++){
21 sum+=Power(counter,exp); /*在此处调用Power函数*/
22 }
23 return(sum);
24 }
25 double Power(double base,int exponent)
26 {
27 int counter;
28 double result;
29 result=1;
30 for(counter=1;counter<=exponent;counter++){
31 result*=base;
32 }
33 return(result);
34 }
35
- jiangpeng
- 帖子: 223
- 注册时间: 2006-07-25 9:33
- 联系:
Re: 变成可执行文件 总会提示有错误
abfunction3.c是源文件,a.out才是编译后的可执行文件
Take what man makes and use it, But do not worship it, For it shall pass. -- Anonymous
Twitter @jiangpeng
Twitter @jiangpeng
- shenglongr
- 帖子: 143
- 注册时间: 2008-11-05 20:55
- 联系:
Re: 变成可执行文件 总会提示有错误
那python文件呢 可执行文件怎么办
- xhy
- 帖子: 3916
- 注册时间: 2005-12-28 1:16
- 系统: Ubuntu 12.10 X64
- 来自: 火星
- BigSnake.NET
- 帖子: 12522
- 注册时间: 2006-07-02 11:16
- 来自: 廣州
- 联系:
Re: 变成可执行文件 总会提示有错误
python 文件就是自己本身, python 是脚本语言, C 是编译语言shenglongr 写了:那python文件呢 可执行文件怎么办
^_^ ~~~
要理解递归,首先要理解递归。
地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
要理解递归,首先要理解递归。
地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
- shenglongr
- 帖子: 143
- 注册时间: 2008-11-05 20:55
- 联系:
Re: 变成可执行文件 总会提示有错误
那怎么能把python的文件
比如myfirst.py
用chmod a+x myfirst.py
之后
./myfirst.py
能够成功 不提示错误呢
难道我看的那个教程有问题
教程表示的是可以的 呵呵
比如myfirst.py
用chmod a+x myfirst.py
之后
./myfirst.py
能够成功 不提示错误呢
难道我看的那个教程有问题
教程表示的是可以的 呵呵
- xhy
- 帖子: 3916
- 注册时间: 2005-12-28 1:16
- 系统: Ubuntu 12.10 X64
- 来自: 火星
Re: 变成可执行文件 总会提示有错误
教程里没说 #!/usr/bin/python或者#!/usr/bin/env python这样一行吗?shenglongr 写了:那怎么能把python的文件
比如myfirst.py
用chmod a+x myfirst.py
之后
./myfirst.py
能够成功 不提示错误呢
难道我看的那个教程有问题
教程表示的是可以的 呵呵
没有说的话就扔掉那个教程
ps: python核心编程很适合入门的,我那本看完了,今天刚送人
目前负债150多万
- shenglongr
- 帖子: 143
- 注册时间: 2008-11-05 20:55
- 联系:
Re: 变成可执行文件 总会提示有错误
c呢 有什么好书 介绍一下
- jiangpeng
- 帖子: 223
- 注册时间: 2006-07-25 9:33
- 联系:
Re: 变成可执行文件 总会提示有错误
Take what man makes and use it, But do not worship it, For it shall pass. -- Anonymous
Twitter @jiangpeng
Twitter @jiangpeng
- shenglongr
- 帖子: 143
- 注册时间: 2008-11-05 20:55
- 联系:
Re: 变成可执行文件 总会提示有错误
恩 看书 解决这个问题了
是没有在前面加上
#! /usr/bin/env python
是没有在前面加上
#! /usr/bin/env python