小编not*_*ing的帖子

Lisp函数调用语法

我试图写一个递归代码,x^y但问题是如何更新代码它给我一个错误.

代码:

    (defun power(x y) (if(> y 0) (* x (power(x (- y 1)))) (1)))
Run Code Online (Sandbox Code Playgroud)

错误:

CL-USER 11 : 5 >Power 2 3
Error: Undefined operator X in form (X (- Y 1)).
Run Code Online (Sandbox Code Playgroud)

错误:

CL-USER 11 : 5 >power(2 3)
Illegal argument in functor position: 2 in (2 3).
Run Code Online (Sandbox Code Playgroud)

lisp syntax-error user-defined-functions

0
推荐指数
2
解决办法
9299
查看次数

文件末尾的C++垃圾

我有一个问题,我不知道如何解决它.问题是:

char * ary = new Char[];

ifstream fle;
fle.open(1.txt, ios_base::binary);
fle.seekg(fle.end);
long count = fle.tellg();
fle.seek(fle.beg);
Run Code Online (Sandbox Code Playgroud)

这是问题:文件1.txt包含:Hello world!.

当我执行时:

ary = new char(count);
fle.read(ary, count);
Run Code Online (Sandbox Code Playgroud)

ary像这样填充:你好世界!@T#^ @ $ @ FF(垃圾)

该文件只是在上面没有任何内容.

平台:赢7,VS 2012

知道如何解决这个问题.(解决了)

(问题2)现在我面临另一个问题,fle.read有时阅读超过我给出的大小.例如,如果我通过像fle.read(缓冲器,1000)它在某些情况下结束(strlen的(缓冲器)= 1500如何可以解决这个问题?

问候,

c++

0
推荐指数
1
解决办法
2270
查看次数

标签 统计

c++ ×1

lisp ×1

syntax-error ×1

user-defined-functions ×1