我有这个代码.
sprintf((char *)pData,"%c%02X%c%02X%
02X",ASCII_STX,m_uSessionId,m_chSequenceChar,m_nMessageId,m_uVersion);
NSLog("%@",pData);
Run Code Online (Sandbox Code Playgroud)
但它是not printing我的contentspData.尝试使用%d格式说明符.
我对下面的程序有疑问.
int main()
{
int i = -3,j = 2, k = 0,m;
m = ++i || ++j && ++k;
printf("%d %d %d %d\n", i, j, k, m);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我把输出作为-2 2 0 1.
在或运算,如果第一个值是真实的,那么它不会评价:第二个这样i = -2和j =2.然后是AND操作.它会检查两个值是否为真.如果那样的k = 1话m = 1.所以输出应该是-2 2 1 1.我跑,检查并得到输出,-2 2 0 1但我无法理解如何.
以下代码在infinte循环中运行.'i'已经使用值1进行初始化,然后与0进行比较.
所以printf()stmt应该执行一次,但它运行infinetly.
unsigned int i = 1;
for (; i >= 0; i--) {
printf("Hello: %u\n",i);
}
Run Code Online (Sandbox Code Playgroud)
请解释一下这种行为.
8位,16位,32位,64位操作系统具有不同的整数,浮点和双精度值数据范围.
这是编译器还是处理器(8位,16位,32位,64位).
如果在网络中如果将来自一个系统的16位整数数据传输到32位系统,反之亦然,则数据将在内存中正确表示.请帮助我理解.
请帮我理解下面的程序.
#include<stdio.h>
int main()
{
int a[7];
a[0] = 1976;
a[1] = 1984;
printf("memory location of a: %p", a);
printf("value at memory location %p is %d", a, *a);
printf("value at memory location %p is %d", &a[1], a[1]);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
&a[1]和&a+1.它们是相同还是不同?
#include <stdio.h>
int main()
{
int v[10];
int **p;
int *a[5];
v[0] = 1234;
v[1] = 5678;
a[0] = v;
a[1] = v+1;
printf("%d\t%d\t%d\t%d\n", *a[0],*a[1],a[0][0],**a);
printf("%d\n", sizeof(v));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
我想知道*a[5]在记忆中是如何表现的.是*a指向的基指针a[0],a[1],a[2],a[3],a[4] …
#include<stdio.h>
void print_hello(void);
int factorial(int n);
Run Code Online (Sandbox Code Playgroud)
#include<stdio.h>
#include<functions.h>
int main()
{
print_hello();
printf("\nThe factorial is: %d \n",factorial(5));
return 0;
}
Run Code Online (Sandbox Code Playgroud)
#include<stdio.h>
#include<functions.h>
void print_hello()
{
printf("\nHello World!\n");
}
Run Code Online (Sandbox Code Playgroud)
#include<stdio.h>
#include<functions.h>
int factorial(int n)
{
if(n!=1)
{
return(n*factorial(n-1));
}
else
return 1;
}
Run Code Online (Sandbox Code Playgroud)
exec : \
compile
echo "Executing the object file"
./compile
compile : main.o hello.o factorial.o
echo "Compiling"
gcc -o compile $^
main.o : main.c functions.h
gcc -c main.c -I./INCLUDE -I./SRC
hello.o : hello.c …Run Code Online (Sandbox Code Playgroud) 1 #include<stdio.h>
2 #include<malloc.h>
3
4 typedef struct node_t{
5 int i;
6 struct node_t* link;
7 }node;
8
9 node* head = (node *)malloc(sizeof(node));
10
11 if(head == NULL){
12 printf("\n malloc for head node failed! \n");
13 }
14
15 int main(){
16 int i = 10;
17 node* temp = NULL;
18 temp = (node *)malloc(sizeof(node));
19 if(temp == NULL){
20 printf("\n malloc for temp node failed! \n");
21 }
22 else{
23 while(i<=10){
24 ;
25 …Run Code Online (Sandbox Code Playgroud) 我正在尝试理解C函数的汇编代码.我无法理解为什么andl -16要在主要方面完成.是为局部变量分配空间.如果subl 32是这样,为什么要为主要做.
我无法理解拆卸的func1.随着读取,堆栈从高阶地址增长到8086处理器的低阶地址.那么为什么在ebp的正侧(对于参数偏移)进行访问以及为什么不在ebp的负侧进行访问.func1中的局部变量是3 +返回地址+保存的寄存器 - 所以它必须是20,但为什么它是24?(subl $24,esp)
#include<stdio.h>
int add(int a, int b){
int res = 0;
res = a + b;
return res;
}
int func1(int a){
int s1,s2,s3;
s1 = add(a,a);
s2 = add(s1,a);
s3 = add(s1,s2);
return s3;
}
int main(){
int a,b;
a = 1;b = 2;
b = func1(a);
printf("\n a : %d b : %d \n",a,b);
return 0;
}
Run Code Online (Sandbox Code Playgroud)
汇编代码:
.file "sample.c"
.text
.globl add …Run Code Online (Sandbox Code Playgroud) #!/usr/bin/perl
use strict;
use warnings;
my $string = "praveen is a good boy";
my @try = split(/([a,e,i,o,u]).*\1/,$string);
print "@try\n";
Run Code Online (Sandbox Code Playgroud)
我试图在给定的字符串中打印包含2个相邻元音的所有单词.
o/p:必须是"praveen"和"good".
我尝试使用否定exp [^]来分割并仅给出2个相邻的元音.