我正在通过一个例如pgm来创建一个make文件.
http://mrbook.org/tutorials/make/
我的文件夹eg_make_creation包含以下文件,
desktop:~/eg_make_creation$ ls
factorial.c functions.h hello hello.c main.c Makefile
Run Code Online (Sandbox Code Playgroud)
# I am a comment, and I want to say that the variable CC will be
# the compiler to use.
CC=gcc
# Hwy!, I am comment no.2. I want to say that CFLAGS will be the
#options I'll pass to the compiler
CFLAGS=-c -Wall
all:hello
hello:main.o factorial.o hello.o
$(CC) main.o factorial.o hello.o -o hello
main.o:main.c
$(CC) $(CFLAGS) main.c
factorial.o:factorial.c
$(CC) $(CFLAGS) factorial.c
hello.o:hello.c
$(CC) $(CFLAGS) hello.c
clean: …
Run Code Online (Sandbox Code Playgroud) int main()
{
matrix[2][4] = {{11,22,33,99},{44,55,66,110}};
int **ptr = (int**)matrix;
printf("%d%d",**matrix,*ptr);
}
Run Code Online (Sandbox Code Playgroud)
但是当一个2-d数组作为参数传递时,它被转换为(*matrix)[2] ..编译器将这个数组存储为什么类型...是存储为2-d数组还是双指针或指向数组的指针.如果它作为数组存储,它如何在不同的情况下如上所述进行不同的解释.请帮我理解.
为什么下面这个程序没有显示任何错误?
int main (void) {
"ANGUS";
1;
3.14;
return 0;
}
Run Code Online (Sandbox Code Playgroud) 我是iPhone开发的初学者.我正在尝试下面的示例程序.
我没有在类B.中调用+(void)初始化和 - (id)init方法.但是它会被自动调用.
- (void)intialise是否等于Objective C中的默认构造函数.
[super init]是否指向NSObject.
如果我没有使用 - (id)init方法,我会收到一个警告,表明该类的实现不完整.
ClassA.h
#import <Foundation/Foundation.h>
static int ab;
@interface ClassA : NSObject {
int a;
}
+ (void) initialize;
- (id) init;
- (void) displayNumOfInstance;
- (void) disp;
@end
Run Code Online (Sandbox Code Playgroud)
ClassA.m
#import "ClassA.h"
@implementation ClassA
+ (void) initialize
{
ab=0;
}
- (id) init
{
self = [super init];
if (self!=nil) {
ab++;
}
return self;
}
- (void) displayNumOfInstance
{
NSLog(@"Number of instances of this class:%d",ab);
}
- (void) disp …
Run Code Online (Sandbox Code Playgroud) 该printf()
函数将返回打印的字符数.但是在下面的代码中为什么要打印5.
int a=1000;
printf("%d",printf("\n%d",a));
Run Code Online (Sandbox Code Playgroud)
它打印"1000"一次和一个空格,所以总共我们有2个字符.
它应该输出"1000 2".但它的输出"1000 5".
void mi_start_curr_serv(void){
#if 0
//stmt
#endif
}
Run Code Online (Sandbox Code Playgroud)
我在编译器中收到错误"错误:输入结束时的预期声明或语句".我找不到上述功能的任何错误.请帮我理解这个错误.
00018 void *memcpy(void *dst, const void *src, size_t len)
00019 {
00020 size_t i;
00021
00022 /*
00023 * memcpy does not support overlapping buffers, so always do it
00024 * forwards. (Don't change this without adjusting memmove.)
00025 *
00026 * For speedy copying, optimize the common case where both pointers
00027 * and the length are word-aligned, and copy word-at-a-time instead
00028 * of byte-at-a-time. Otherwise, copy by bytes.
00029 *
00030 * The alignment logic below should …
Run Code Online (Sandbox Code Playgroud) 通过readelf检查目标文件的反汇编时,我看到数据和bss段包含相同的偏移地址.数据部分将包含初始化的全局变量和静态变量.BSS将包含非主动化的全局变量和静态变量.
1 #include<stdio.h>
2
3 static void display(int i, int* ptr);
4
5 int main(){
6 int x = 5;
7 int* xptr = &x;
8 printf("\n In main() program! \n");
9 printf("\n x address : 0x%x x value : %d \n",(unsigned int)&x,x);
10 printf("\n xptr points to : 0x%x xptr value : %d \n",(unsigned int)xptr,*xptr);
11 display(x,xptr);
12 return 0;
13 }
14
15 void display(int y,int* yptr){
16 char var[7] = "ABCDEF";
17 printf("\n In display() function \n"); …
Run Code Online (Sandbox Code Playgroud) 我必须编写一个程序,可以计算2 power 2010
和找到数字之和的权力.例如:
if `2 power 12 => gives 4096 . So 4+0+9+6 = 19 .
Run Code Online (Sandbox Code Playgroud)
现在我需要找到相同的 2 power 2010.
请帮我理解.