有没有办法让ARGV []函数加倍?
我试过这个,但它没有按照我想要的方式工作。我的“解决方案”代码是:
int MarkGenerator(double argc,double argv []){ 如果(…
以下是一些建议的更改。
#include<stdio.h> #include<stdlib.h>
// argc是一个int,而argv是一个char *的数组
int MarkGenerator(int argc, char * argv[]) { if (argc < 3){ OnError("Too few arguments for mark calculator", -3); }else{ // The function gets its arguments as strings (char *). // Take each of the strings and convert it to double double MaxPoint = strtod(argv[1], NULL); double PointsReached = strtod(argv[2], NULL); double temp = 0; temp = PointsReached * MaxPoint; // Use "%lf" to print a double printf("%lf\n", temp); temp = temp * 5; printf("%lf\n", temp); temp = temp ++; printf("%lf\n", temp); } }
// main函数的标准签名
int main(int argc, char * argv[]) { // Note how arguments are passed MarkGenerator(argc, argv); }