由买买提看人间百态

topics

全部话题 - 话题: printf
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)
W*****x
发帖数: 684
1
$ cd geoip-api-c-master
$ libtoolize
$ aclocal
$ autoconf
$ automake --add-missing
$./configure
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
... 阅读全帖
q***z
发帖数: 934
2
来自主题: Programming版 - A thread question
Hello I am new on threads.
I am reading this example code, however, I can't understand it,
even though I search the usage of setpid, umask.
Can anyone explain it for me?
What's daemon?
Thank you very much!
#include
#include
int daemon_init(void)
{pid_t pid, pid1;
if((pid=fork())<0) exit(-1);
else if(pid)
{printf("pid=%d\n",(int)pid);e­xit( 0);} /* parent */
/* child */
printf("uid=%d gid=%d egid=%d \n",
(int) getuid(),(int) getgid(),(int) getegid() );
c******n
发帖数: 4965
3
来自主题: Programming版 - Help!! variable scope ????
I think I read somewher before that
the scopes of global variables in C are not cleanly defined
if you have multiple definitions of a variable in different files,
some compilers take them to be "static", some take as "global"
e.g. I have a.c, and b.c
////////////////////////////
// a.c
int n;
void fun();
void main(){
n=1;
fun();
printf("main: %d\n", n);
}
//////////////
// b.c
int n;
void fun(){
n=2;
/////////////////////////////////
// b.c
int n;
void fun(){
n=2;
printf("fun(): %d
k*k
发帖数: 508
4
来自主题: Programming版 - 一个简单的算法问题?
========================
int M=xxx;
int N=yyy;
void print_result(int* arr)
{
int i;

for (i=0;i printf("%d ", arr[M]);
printf("\n");
}
void perm(int* arr, int k)
{
int i;
for (i=0;i {
arr[k]=data[i][k];
if (k perm(arr, k+1)
else
print_result(arr);
}
}
int main()
{
// initialize data array (N*M)
.....
int *arr;
arr=(int*)malloc(M*sizeof(int));
perm(arr, 0
l*******h
发帖数: 3
5
来自主题: Programming版 - C/C++函数调用和栈内存
这几天学C语言学晕了,都因是看内存管理变量分配的问题.现在看RETURN语句都不顺眼.
比如下面第一个CODE,因为B指针指向栈内存,离开fun2()就失效,所以返回main()的结果
不正确.
int *fun2(void)
{
int b=2;
return &b;
}
main()
{
int *b1=fun2();
printf(“%\n”, *b1);
}
那下面的CODE就对了吗? 变量b在fun1()子程序里不也是在栈内存吗?它离开fun1()子程
序不也无效了吗?怎能指望返回MAIN正确的值呢? RETURN 这个命令是怎么和把什么返回
主函数的?
int fun1(void)
{
int b=2;
return b;
}
main()
{
int b1=fun1();
printf(“%\n”, b1);
}
p**p
发帖数: 3386
6
来自主题: Programming版 - select的timeout怎么不work
在一个while循环里面用select来判断数据是否准备好,设置了5秒的timeout。
照理说如果没有设备准备好,select等待5秒后会出现timeout,然后返回0。但是在运
行中select不停的返回0,根本不等5秒。这是怎么回事啊?下面是代码:
n = select(max_fd,&input, NULL,NULL,&timeout);
if (n<0) {perror("select");exit(-1);}
if (n==0) {
printf("Read timeout\n");
}
else printf("Data is ready\n");
a*******y
发帖数: 1040
7
来自主题: Programming版 - 这个是什么原因
class AA
{
public:
AA() : _i(2), _j(_i) {}
int _j, _i;
};
void
fff()
{
AA a;
printf("%d\n", a._i);
printf("%d\n", a._j);
}
输出是2
1
为什么不是2
2
B********s
发帖数: 3610
8
来自主题: Programming版 - 请问如何恢复正常的IO?
帮忙看看这段代码为什么不能把输出重定向到屏幕?
int main()
{
int fdout;
fdout = open("a",O_WRONLY|O_CREAT|O_TRUNC,S_IRUSR|S_IWUSR|S_IRGRP|S_IROTH);
dup2(fdout,STDOUT_FILENO);
printf("hehe\n");
dup2(1,STDOUT_FILENO);
printf("haha\n");
return 0;
}
r*******y
发帖数: 290
9
来自主题: Programming版 - 一个面试题
main()
{
printf("..."); //the first statement
..............
}
问该程序有没有可能在printf之前崩溃
y*w
发帖数: 238
10
来自主题: Programming版 - solidot上看来的
int main () {
int i=2;
if( -10*abs (i-1) == 10*abs(i-1) )
printf ("OMG,-10==10 in linux!\n");
else
printf ("nothing special here\n");
}
同样的C代码,在windows和unix系统中编译运行的结果是nothing special here,只有
linux得到是-10==10。恩,我们的gcc在这里犯了一个低级错误。"
http://linux.solidot.org/linux/07/11/19/0512218.shtml
z***e
发帖数: 5393
11
void change(const char* s) //s="abcdefg"
{
char* a=NULL;
a=(char*)s;
*a='*';
printf("%c\n",*a); //第一次输出*
printf("%c\n",*a); //第二次输出a
}
int main()
{
const char *s="abcdefg";
change(s);
}
为什么第一次输出*?vc下运行。
c***g
发帖数: 472
12
来自主题: Programming版 - 谁帮我解释一下这个代码
#include
#include
main(){
typedef union {
int a;
char b[10];
float c;
}
Union;
Union x,y ={100};
x.a = 50;
strcpy(x.b,"hello");
x.c = 21.50;
printf("Union x: %d %s %f \n",x.a,x.b,x.c);
printf("Union y: %d %s %f \n",y.a,y.b,y.c);
}
为什么我的输出是
Union x: 1101791232 21.500000
Union y: 100 d 0.000000
c***d
发帖数: 996
13
☆─────────────────────────────────────☆
blogrance (AM) 于 (Fri May 25 10:22:34 2007) 提到:
系统:学校服务器redhat linux
GCC compiler version 3.23...
问题:MAKE 产生 core dump, error 139. 狗狗了半天,说有可能是compiler 版本太
老,或者是swap 空间不够,检查swap空间足够,GCC版本学校控制。程序是一个1000行
左右的数学运算。
另外一个可能相关的问题是,如果更改程序里的打印语句,程序输出文件显示程序运行
到不同的地方。
比如:

printf("test 2\n");
comment 掉,之前输出文件可能显示
。。。。。
test 4
但是更改之后,输出文件显示程序中止在不同地方,甚至有时候是一个打印语句的中间。
比如:
printf("check again\n");
输出文件最后一行显示
check
again is missing...
哪位大拿对这个error 139 有研究,指点一下,不胜感谢,
P********e
发帖数: 2610
14
来自主题: Programming版 - 一道c++的考古题
run this on g++
#include "stdio.h"
#include
int main()
{
int i=2;
if( -10*abs (i-1) == 10*abs(i-1) )
printf ("OMG,-10==10 in linux!\n");
else
printf ("nothing special here\n");
return 0;
}
M*m
发帖数: 141
15
来自主题: Programming版 - C, how is a string cast into a int?
Looks like j is the address of the string. but here is another problem.


int main(){

char *a = "12";

int t = (int)a;

printf ("%d\n", t);

printf("%c\n", *((char *)t
p****s
发帖数: 32405
16
来自主题: Programming版 - 一个读用户输入的小问题
C program. 我想先写个小测试, 如果逻辑对的话再往我的UI上套。
逻辑就是,在输入参数时,如果用户不想改任何设置,直接按回车我就给他一个缺省值;
否则我把it的非空键盘输入读进来.
src是这样:
int _tmain(int argc, _TCHAR* argv[])
{
int i = 2575000;
printf("Enter a number: ");
if (getchar()!= '\n')
scanf_s("%d%*c",&i);
printf("You entered the number %d \n",i);
return 0;
}
运行结果:
C:\Projects\readchatest\debug> readchartest.exe
Enter a number:
You entered the number 2575000
C:\Projects\readchatest\debug>readchartest.exe
Enter a number: 12345
You entered the number 2345
问题很明显,我用getc
p**********g
发帖数: 9558
17
来自主题: Programming版 - 这个函数有问题吗?
多些讨论
在isr里,如果调用printf会有什么问题?假设printf是可以call的
p**********g
发帖数: 9558
18
来自主题: Programming版 - 一道算法题求教,
#include
#include
int depth[10];
int idx=0;
void display(void)
{
int i;
for(i=0;i printf("%d+", depth[i]);
printf("\n");
}
void sum(int in, int delta)
{
int i;
int op = in;
int step = 1;
if(delta<0) return ;
if(delta==in)
{
depth[idx++] = delta;
display();
depth[--idx] = 0;
}
else
while(1)
{
step = 10*step;
if(op/step)
{
if(
h**o
发帖数: 548
19
the debug line in the C code is quite long:
printf("set original GIF to detailed with factor=%d because image is to be
resized\n",http->request->bmi.gifDecimateFactor);
I want to seperate it to be two lines:
printf("set original GIF to detailed with factor=%d
because image is to be resized\n",http->request->bmi.gifDecimateFactor);
what operator should I insert between 'factor=%d'and 'because'?
Thanks
s********1
发帖数: 581
20
Thanks for your reply.
为什么在main.c用standard library 中的函数,例如printf时,只需在main.c 中
#include , 在compile 时完全不必提及printf 所在的 .c source file???

chunks,
line.
or
p*******n
发帖数: 273
21
来自主题: Programming版 - 再问一个free()的问题
多谢. 发现free()之后还可以对原来的内存访问,free的作用到底是什么?
#include
#include
char *mkarray()
{
char *a;
a=(char *)malloc(4*sizeof(char));
a[0]='a';a[1]='r';a[2]='e';a[3]='y';
return (a);
}
int main()
{
char *b,*c;
b=mkarray();
c=b+2;
free(b);
printf("%c %c %c %c\n",b[0],b[1],b[2],b[3]);
printf("%c %c \n",c[0],c[1]);
return 0;
}
输出结果是
a r e y
e y
w******g
发帖数: 67
22
来自主题: Programming版 - two general C++ question
We know "printf" and "system" are "C" functions. Although we can use them in
C++, I wonder
1.For formatting the output and string, are there similar functions like "
printf" and "sprintf" in C++?
2.For running external program in C++, are there similar functions like "
system" and "popen" in C++?
s***e
发帖数: 122
23
这种一般都只好用printf去查了。我只有一个有一点点类似的例子:调别人写好的程序
,用的是Fortran,在SunOS和Linux上的结果不一样,后来发现是有一个变量没有初始
化,在SunOS上被初始化为0,但是在Linux就没有。我觉得多用些printf,二分法分段
猜测,花些时间应该就能找出来,就是最后会感叹,写程序容易调程序难 :O)
b***y
发帖数: 2799
24
来自主题: Programming版 - [合集] 一道C++面试题 (转载)
☆─────────────────────────────────────☆
DVD (时不我待) 于 (Sat Nov 1 22:48:07 2008) 提到:
发信人: siriusliu (天狼), 信区: JobHunting
标 题: 一道C++面试题
发信站: BBS 未名空间站 (Fri Oct 31 15:29:55 2008)
给了一个code:
#include
class A {
public:
A(){f();}
virtual void f(){printf("A");}
};
class B : public A {
public:
B(){f();}
virtual void f(){printf("B");}
};
int main()
{
B myB;
A *myBP;
B *myBP2;
myBP=new B(
b******w
发帖数: 52
25
来自主题: Programming版 - question on divide by zero
I have the following quesitons on divide by zeros, could somebody explain to
me
why it is so?
Question 1:
int a = 1, b = 0;
int c = a/b;
printf("%f", c);
I will get float point exception at the line c = a/b, but here all a, b, c
are integers? why a float point exception is invoked?
Qustion 2:
float a = 1.0, b = 0.0;
float c = a/b;
printf("%f", c);
the output is: inf
could somebody explain the two results to me?
Thanks!
s******a
发帖数: 318
26
又写了个简单的code:
int main()
{
printf ("Adding something into out.txt");
FILE* fp;
int i = 100;
char * ch = "XXXXXXy";
fp=fopen("out.txt", "w");
while (i > 0)
{
sleep (1);
fprintf(fp, "%s", ch);
fflush(stdout);
printf ("ADDD");
i--;
}
}
编译没有问题,但是out.TXT文件根本就没有被写入,但是如果注释掉sleep语句就可以
写入,请问这是为什么?
s*****n
发帖数: 461
27
来自主题: Programming版 - c preprocess question
为什么line1合法,line2非法?
#include
#define f(a,b) a##b
#define g(a) #a
#define h(a) g(a)
int main(void)
{
printf("\n%s", g(f((1,2),3)) ) ; /*line1*/
printf("\n%s", h(f((1,2),3)) ) ; /*line2*/
}
e******d
发帖数: 310
28
来自主题: Programming版 - A question about singleton
In the following code for Singleton, why will the destructor be
called again and again??
Thank you.
=============================
#include "stdio.h"
class Singleton
{
public:
static Singleton* create_obj();
~Singleton()
{
printf("Destor is called \n");

if(psig != NULL)
delete psig;
}
private:
Singleton() { printf("Contor is called \n"); }
static Singleton* psig;
};
Singleton* Singleton::psig = NULL;
Singleton* Singleton::create_
X****r
发帖数: 3557
29
来自主题: Programming版 - Help needed on coding for Fibonacci series
I didn't look closely at your code, but it seems way too complicated
at first glance. Why don't you just use recursion? The code should be
very simple, like:
void printStepsImpl(int x[], int k, int n) {
if (n--) {
x[k] = 1;
printStepsImpl(x, k+1, n);
if (n--) {
x[k] = 2;
printStepsImpl(x, k+1, n);
}
} else {
int i;
for (i = 0; i < k; i++) {
printf("%d ", x[i]);
}
printf("\n");
}
}
void printSteps(int n) {
int x[n]; // gcc extension, or t
t****t
发帖数: 6806
30
来自主题: Programming版 - 问个c++问题
你这个要求不明确. 一个参数要的是float, 你怎么提出这个要求呢?
比如说printf family, 是printf("%f", x), 那么x应该是一个double, 这个"x是
double"的要求是作为第一个参数提出来的.
所谓type check, 是指在编译时就有这样的保证. 刚才我举的例子就没有这样的保证,
而且用第一个参数作出的要求也不可能在编译时就得到这样的保证.
X****r
发帖数: 3557
31
来自主题: Programming版 - tree data conversion
右边第一行应该是1->2,不是1->1吧。
我不懂perl,不过这个程序实在简单,用C写一个也就几行:
int expand(int input[], int output[][2], int start) {
int branch, end = start + 1;
for (branch = 0; branch < input[start]; ++branch) {
output[start][branch] = end;
end = expand(input, output, end);
}
return end;
}
验证程序:
#include
#include
#define MAX 100
int main(int argc, char *argv[]) {
int input[MAX], output[MAX][2] = {0};
int i;
for (i = 1; i < argc; ++i) {
input[i] = atoi(argv[i]);
}
printf... 阅读全帖
d**d
发帖数: 389
32
来自主题: Programming版 - 请教一个linux下的POSIX timer的问题。
我用linux下面的POSIX timer, timer_create(),timer_settime(),
为什么在调用了timer_settime()以后,立马就有一个time-out callback? 然后再每过
5秒后有一个time out?
难道不是我调用timer_settime()以后,timer开始计时, 等到5秒以后再出现第一
time out callback 吗?
非常感谢!
代码如下:
#include
#include
#include
#include
#include
void
handle (sigval_t v)
{
time_t t;
char p[32];
time (&t);
strftime(p,sizeof(p),"%T ",localtime(&t));
printf("%s thread 0x%x,val=%d,signal captured.... 阅读全帖
h****a
发帖数: 70
33
来自主题: Programming版 - 再问个fork的题 (转载)
【 以下文字转载自 Linux 讨论区 】
发信人: himdca (how are you doing?), 信区: Linux
标 题: 再问个fork的题
发信站: BBS 未名空间站 (Thu Jun 9 03:31:30 2011, 美东)
Given the following code:
#include
int main(void)
{
int tmp;
tmp = fork();
if(tmp == 0)
{
printf("Hello ")
sleep(1)
}
else if(tmp > 0)
{
printf("World, ")
sleep(1)
}
print "Bye bye"
}
Assuming the call to fork doesn't fail, which of the following is true (zero
o... 阅读全帖
j*******e
发帖数: 674
34
来自主题: Programming版 - C signal SIGFPE 问题
下面code在Linux2.6,gcc下运行:
$ ./a.out
Floating point exception (core dumped)
问题:
1. 已经设了process signal mask, 40行产生的SIGFPE应该被屏蔽
2. 32行安装了signal handler, 40行产生的SIGFPE应该被capture
为什么运行结果是直接core dump?
如果注释掉 “z=x/y", 改用“raise(SIGFPE)", 运行结果就符合预期。
难道“z=x/y"在这里不是rasie SIGFPE 吗?
=============================
#include
#include
#include
void sig_handler(int signum)
{
printf("sig_handler() received signal %d\n", signum);
}
int main(int argc, char * argv[])
{
// setup signal... 阅读全帖
t****t
发帖数: 6806
35
来自主题: Programming版 - c++ pointer conversion question
let me show you an example:
/* 1.c */
#include
void bar(int* a, float* b)
{
a[5]=200;
b[5]=1.0;
printf("%d\n", a[5]);
printf("&a[5]=%p &b[5]=%p\n", a+5, b+5);
}
/* 2.c */
void bar(int*, float*);
int main()
{
int a[10];
float* b=(float*)a;
bar(a, b);
}
What do you think the result is?
compile with -O2 and -O0, you get different results:
$ gcc -O0 1.c 2.c
$ a.out
1065353216
&a[5]=0x7fffb3828964 &b[5]=0x7fffb3828964
$ gcc -O2 1.c 2.c
$ a.out
200
&a[5]=0x7fff2e7... 阅读全帖
a****l
发帖数: 8211
36
来自主题: Programming版 - c++ pointer conversion question
is it possible that b[5]=1.0 got deleted by the optimization process? E.g.,
if we do like this:
volatile int k;
void bar(int* a, float* b)
{
a[5]=200+k;
b[5]=1.0+k;
k = a[5]*b[5];
printf("%d,%d,%d\n", a[5],b[5],k);
printf("&a[5]=%p &b[5]=%p\n", a+5, b+5);
}
will that make any difference with different optimization switch?
v******l
发帖数: 512
37
来自主题: Programming版 - c++ pointer conversion question
First, I suppose your last statement should be:
printf("%d\n", a[0]);
OR
printf("%d\n", *a);
because otherwise you're printing a pointer as an integer, which does not
make much sense here.
With that change, I doubt this sample will ever print 200 at all because you
clearly give the compiler that logic you want (unlike that last sample you
deliberately hide the fact from the compiler that the two pointers are to
the same address). I'm pretty sure it will print 1065353216 on any 32/64-bit
small-en... 阅读全帖
d****n
发帖数: 1637
38
Sorry being a noobie.
this should be what I was talking about.
the 1st version was wrong.
#######################################
#include
void swap(void **firstPtr, void **secondPtr)
{
void *temp = *firstPtr;
*firstPtr = *secondPtr;
*secondPtr = temp;
return;
}
int main()
{
int a = 10;
int b = 20;
int *aPtr = &a;
int *bPtr = &b;
printf("Before Swapping, Address : %x %x, Value : %d %d\n", aPtr, bPtr,
*
aPtr, *bPtr);
swap(&aPtr, &bPtr);
printf("After Swapping, Address : %x %x, Value : %... 阅读全帖
d****n
发帖数: 1637
39
来自主题: Programming版 - C++ Q110: Add without +
狗来的:
#include
int add(int a, int b)
{
if (!a)
return b;
else
return add((a & b) << 1, a ^ b);
}
int main()
{
unsigned int a,b;
printf("Enter the two numbers: \n");
scanf("%d",&a);
scanf("%d",&b);
printf("Sum is: %d",add(a,b));
}
g*****1
发帖数: 998
40
来自主题: Programming版 - 请教一道c/c++题
char *m()
{
char str[50];
strcpy(str,"how are you");
return str;
}
int main()
{
char s[50];
strcpy(s,m());
printf("%s",s);
//cin.get();
return 0;
}
为什么结果可以正确输出呢?我知道return by pointer可以make copy,可是return之
后storage不是free了吗?
另外,为什么下面这个就只能由一部分正确输出?
char *m()
{
char str[20];
strcpy(str,"how are you");
return str;
}
int main()
{

printf("%s",m());
//cin.get();
return 0;
}
然后上面char str[20];改成比如char str[50],输出就完全是乱得了
p*********t
发帖数: 2690
41
来自主题: Programming版 - 请教一道c/c++题
2网友的意见不同,哪个是对的?
newpolice -- function char *m() {} is valid
Xentar -- it's undefined.

char *m()
{
char str[50];
strcpy(str,"how are you");
return str;
}
int main()
{
char s[50];
strcpy(s,m());
printf("%s",s);
//cin.get();
return 0;
}
为什么结果可以正确输出呢?我知道return by pointer可以make copy,可是return之
后storage不是free了吗?
另外,为什么下面这个就只能由一部分正确输出?
char *m()
{
char str[20];
strcpy(str,"how are you");
return str;
}
int main()
{

printf("%s",m());
//cin.get();
return 0;
}
然后上面char str[20];改成比如cha... 阅读全帖
g***i
发帖数: 4272
42
7.写出下面代码片段的输出。
int **p1 = 0;
p1++;
printf("%d\n", (int)p1+2);
int (*p2)[10] = 0;
p2++;
printf("%d\n", (int)p2);

6 or 10, depends on machine. sizeof(int **)==8 here
40
d****n
发帖数: 1637
43
来自主题: Programming版 - 请教一个C语言的面试题
use macro , no need to calculate the constant
~~~~~~
#include
#define SETN( x ,n) ((x)|=(1<<(n)))
#define UNSETN(x, n) ((x)&=~(1<<(n)))
int main(){
unsigned short int i=1;
SETN(i, 9) ;
printf("%d\n",i);
UNSETN(i, 9) ;
printf("%d\n",i);
}
///output
513
1
z*****n
发帖数: 447
44
比如:
#include
class f{
public:
virtual void p(){printf("father\n");}
};
class c : public f{
public:
void p(){
printf("child\n");
}
};
--------------------------------------
Derived Class 调用Base Class可以这样:
f *a = new c;
a->f::p(); // 这里Print的是"father"
---------------------------------------
如果
f *b = new f;
b怎样才可以调用到 c的method p()
多谢!
z*****n
发帖数: 447
45
比如:
#include
class f{
public:
virtual void p(){printf("father\n");}
};
class c : public f{
public:
void p(){
printf("child\n");
}
};
--------------------------------------
Derived Class 调用Base Class可以这样:
f *a = new c;
a->f::p(); // 这里Print的是"father"
---------------------------------------
如果
f *b = new f;
b怎样才可以调用到 c的method p()
多谢!
l***y
发帖数: 4671
46
能展开讲讲数组的数组么?一直理解为一维数组名本身就是指针,所以数组的数组本身
就是个一维的指针的数组。
刚测过,memset 和多重循环比起来的确是一个数量级,不开 -O3 时差别大约三倍,打
开 -O3 后 loop 比 memset 更快。但是在我的实际 code 里,memset 比 loop 大概要
快两个数量级 -- 天知道怎么回事。。。
double A[1000][1000] = {{0}};
clock_t t_start = -1;
t_start = clock();
for (int ind = 0; ind < 1000; ind++)
for (int i = 0; i < 1000; i++)
for (int j = 0; j < 1000; j++)
A[i][j] = 0;
t_start = clock() - t_start;
printf("Loop takes %f sec; ", t_start/(double)(CLOCKS_PER_SEC));
t_start = cloc... 阅读全帖
d****n
发帖数: 1637
47
sz=10
arr[sz]={0,1,2,3,4,5,6,7,8,9}
int i;
for(i=0;i<(int)sz/2;++i){
printf("%d %d ", arr[i],arr[sz-i-1]);
}
if(sz%2==1) printf(" %d ",arr[sz/2+1]);
d****n
发帖数: 1637
48
g(f(1,2)) -> g(a) 把 f(1,2) stringfy 了, stringfy 了就不能再扩展了
int main()
{
printf("%s\n","12");
printf("%s\n","f(1,2)");
return 0;
}
###回答的不满意?还是没包子,QQ
d****n
发帖数: 1637
49
来自主题: Programming版 - 10个包子请教一个简单的编程问题
递归的
#include
#include
void print_a(int a[], int n){
int i;
for(i=0;i printf("%d ", a[i]);
}
printf("\n");
}
void loop(int a[], int n, int N ){
if(n==0){print_a(a, N) ;return;}
int i;
for(i=0;i a[n-1]=i;
loop(a, n-1, N);
}
}
int main(){
int N=6;
int a[N] ;
loop( a, N, N);
}
c*******y
发帖数: 1630
50
来自主题: Programming版 - 弱问一个virtual function的问题
不确定的话,用debugger看看好了。或者
#include
class base{
public:
void test(){}
};
class derived: public base{
};
int main(){
printf("%p\n", &base::test);
printf("%p\n", &derived::test);
}

了?
首页 上页 1 2 3 4 5 6 7 8 9 10 下页 末页 (共10页)