变成可执行文件 总会提示有错误

软件和网站开发以及相关技术探讨
回复
头像
shenglongr
帖子: 143
注册时间: 2008-11-05 20:55
联系:

变成可执行文件 总会提示有错误

#1

帖子 shenglongr » 2008-11-30 8:38

新手学习 遇到点问题 希望大家帮助 得到解决

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: 变成可执行文件 总会提示有错误

#2

帖子 jiangpeng » 2008-11-30 11:31

abfunction3.c是源文件,a.out才是编译后的可执行文件
Take what man makes and use it, But do not worship it, For it shall pass. -- Anonymous

Twitter @jiangpeng
头像
shenglongr
帖子: 143
注册时间: 2008-11-05 20:55
联系:

Re: 变成可执行文件 总会提示有错误

#3

帖子 shenglongr » 2008-11-30 12:22

那python文件呢 可执行文件怎么办
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: 变成可执行文件 总会提示有错误

#4

帖子 xhy » 2008-11-30 12:24

shenglongr 写了:那python文件呢 可执行文件怎么办
解释执行的语言 和 编译执行的语言 当然不一样了
目前负债150多万
头像
BigSnake.NET
帖子: 12522
注册时间: 2006-07-02 11:16
来自: 廣州
联系:

Re: 变成可执行文件 总会提示有错误

#5

帖子 BigSnake.NET » 2008-11-30 12:25

shenglongr 写了:那python文件呢 可执行文件怎么办
python 文件就是自己本身, python 是脚本语言, C 是编译语言
^_^ ~~~
要理解递归,首先要理解递归。

地球人都知道,理论上,理论跟实际是没有差别的,但实际上,理论跟实际的差别是相当大滴。
头像
shenglongr
帖子: 143
注册时间: 2008-11-05 20:55
联系:

Re: 变成可执行文件 总会提示有错误

#6

帖子 shenglongr » 2008-11-30 16:37

那怎么能把python的文件
比如myfirst.py
用chmod a+x myfirst.py
之后
./myfirst.py
能够成功 不提示错误呢
难道我看的那个教程有问题
教程表示的是可以的 呵呵
头像
xhy
帖子: 3916
注册时间: 2005-12-28 1:16
系统: Ubuntu 12.10 X64
来自: 火星

Re: 变成可执行文件 总会提示有错误

#7

帖子 xhy » 2008-11-30 16:46

shenglongr 写了:那怎么能把python的文件
比如myfirst.py
用chmod a+x myfirst.py
之后
./myfirst.py
能够成功 不提示错误呢
难道我看的那个教程有问题
教程表示的是可以的 呵呵
教程里没说 #!/usr/bin/python或者#!/usr/bin/env python这样一行吗?
没有说的话就扔掉那个教程

ps: python核心编程很适合入门的,我那本看完了,今天刚送人
目前负债150多万
头像
shenglongr
帖子: 143
注册时间: 2008-11-05 20:55
联系:

Re: 变成可执行文件 总会提示有错误

#8

帖子 shenglongr » 2008-11-30 22:05

c呢 有什么好书 介绍一下
头像
jiangpeng
帖子: 223
注册时间: 2006-07-25 9:33
联系:

Re: 变成可执行文件 总会提示有错误

#9

帖子 jiangpeng » 2008-12-01 15:56

Take what man makes and use it, But do not worship it, For it shall pass. -- Anonymous

Twitter @jiangpeng
头像
shenglongr
帖子: 143
注册时间: 2008-11-05 20:55
联系:

Re: 变成可执行文件 总会提示有错误

#10

帖子 shenglongr » 2008-12-03 15:35

恩 看书 解决这个问题了
是没有在前面加上
#! /usr/bin/env python
回复