c语言指针中and
1. &在c语言中什么意思
主要有两个意思:
取地址符,用在指针表达式或输出变量地址时 例如 int a; &a就是表示变量a在内存中地址
二进制位与位运算符 1&1=1 0&0=0
拓展资料:
C语言主要特点:
C语言是高级语言。它把高级语言的基本结构和语句与低级语言的实用性结合起来。C 语言可以像汇编语言一样对位、字节和地址进行操作,而这三者是计算机最基本的工作单元。
C语言是结构式语言。结构式语言的显着特点是代码及数据的分隔化,即程序的各个部分除了必要的信息交流外彼此独立。这种结构化方式可使程序层次清晰,便于使用、维护以及调试。C 语言是以函数形式提供给用户的,这些函数可方便的调用,并具有多种循环、条件语句控制程序流向,从而使程序完全结构化。
C语言功能齐全。具有各种各样的数据类型,并引入了指针概念,可使程序效率更高。而且计算功能、逻辑判断功能也比较强大。
C语言适用范围大。适合于多种操作系统,如Windows、DOS、UNIX、LINUX等等;也适用于多种机型。 C语言对编写需要硬件进行操作的场合,明显优于其它高级语言,有一些大型应用软件也是用C语言编写的。
2. C语言指针问题
#include<stdio.h>
intmain(){
voidmaxandmin(int*data,int*max,int*min,intlen);
intarr[10],max,min,len=10,i;
for(i=0;i<10;i++)
scanf("%d",arr+i);
maxandmin(arr,&max,&min,len);
printf("max=%d,min=%d ",max,min);
return0;
}
voidmaxandmin(int*data,int*max,int*min,intlen){
inti;
*max=*min=*data;
for(i=1;i<len;i++){
if(*(data+i)>*max)*max=*(data+i);
if(*(data+i)<*min)*min=*(data+i);
}
}
3. C语言中:&&和||符号是什么意思
“&&”表示
与,意为同时都要满足。
“||”表示
或,意为二者或多着只要满足其中一个。
在C语言中,&&和||都属于逻辑运算符,并且都是双目运算符。
逻辑运算符总共有3个,分别是"&&"、"||"和"!"。a
&&
b,一假必假,结合性从左至右。||是逻辑或运算符,a
||
b,一真必真,结合性从左至右。
&&和||在Java和PHP以及c#中都是逻辑操作符,也叫条件操作符。
(3)c语言指针中and扩展阅读
:
c语言中&&是一种双目运算符,表示与运算,而当左边所给表达式或变量为0时,不再计算右
侧,整个表达式为零。
逻辑运算符是用来判断一件事情是"成立"还是“不成立”,或者说是“真”还是“假”,判断的结果只有两个值,用数字表示就是“0”和“非0”。
其中,“非0”表示该逻辑运算的结果是“真”,“0”表示这个逻辑运算表达式的结果为“假”。
参考资料:
搜狗网络-&&
搜狗网络-||
4. C语言中一个指针问题
不同。*(++p)是先让p向后移一单元再输出其中的值;而*(p++)是先输出其中的值再让p向后移一单元。但是,printf函数是从右向左计算参数表的,所以先计算的是*(++p)。这样,p就从指向a[1]变为指向a[2]了;然后再计算*(p++),由于是后++,所以输出还是a[2];然后才作p++操作。所以输出两次a[2],最后p指向a[3].
5. C语言指针问题,求详解!!
feofSee Alsoclearerr
| ferror
Requirements
OS Versions: Windows CE 2.0 and later.
Header:
stdlib.h.
Link Library: coredll.dll.
Tests for end-of-file on a stream.
int feof( FILE* stream
);Parametersstream
Pointer to FILE structure. Return Values
The feof function returns a nonzero value after the first read
operation that attempts to read past the end of the file.
It returns 0 if the current position is not end of file.
There is no error return.
Remarks
The feof routine (implemented both as a function and as a macro)
determines whether the end of stream has been reached.
When end of file is reached, read operations return an end-of-file indicator
until the stream is closed or until fsetpos, fseek, or
clearerr is called against it.
Example
/* FEOF.C: This program uses feof to indicate when
* it reaches the end of the file FEOF.C. It also
* checks for errors with ferror.
*/
#include <stdio.h>
#include <stdlib.h>
void main( void )
{
int count, total = 0;
char buffer[100];
FILE *stream;
if( (stream = fopen( "feof.c", "r" )) == NULL )
exit( 1 );
/* Cycle until end of file reached: */
while( !feof( stream ) )
{
/* Attempt to read in 10 bytes: */
count = fread( buffer, sizeof( char ), 100, stream );
if( ferror( stream ) ) {
printf( "Read error" );
break;
}
/* Total up actual bytes read */
total += count;
}
printf( "Number of bytes read = %d\n", total );
fclose( stream );
}
Output
Number of bytes read = 745Requirements
OS Versions: Windows CE 2.0 and later.
Header:
stdlib.h.
Link Library: coredll.dll.
See Also
clearerr | ferror
Last updated on Wednesday, September 14, 2005
© 2005
Microsoft Corporation. All rights reserved.
6. c语言中 &= 是什么意思
按位与后赋值运算符
7. c语言中指针怎么使用
1、使用场景
使用指针时,必须将它指向一个变量的地址或者为它分配空间方能使用,如下所示:
#include<stdio.h>
#include <stdlib.h>
int main(int argc, char const *argv[])
{
int a[5]={0,1,2,3,4};
int *b,*d;
int c=2;
int *e=a; //e指向a数组首地址
//*b=2; 无法直接初始化
//printf("%d ", *b);
e=e+2; //移动两个地址单元
d=&c; //d指向c的地址来表示值
c=4; //修改原c变量的值,d指针的值会发生改变
b=(int *)malloc(sizeof(int));//为b分配一个int型空间来直接存储值
*b=2;//分配空间后可以直接赋值了
printf("this is e,b,c,d :%d %d %d %d ",*e,*b,c,*d);
2、类型说明
(1)int *a :表示一个指向int型变量的指针,指向的是变量的地址单元
(2)char *b:表示一个指向char变量的指针
*a表示的是这个指针指向地址的值,a为此指针本身的地址,这点要明确,一般用*(a+1)、*(a+2)来表示值,如:
int nums[5]={0,1,2,3,4};
int *a=nums;
printf("%d %d %p ",*a,*(a+1),a);
(7)c语言指针中and扩展阅读:
指针的运算
指针指向变量地址,若原变量的内容发生了变化,它本身也会发生变化,指针之间的运算一般为值运算和地址运算
(1)值运算:直接通过*运算方式,像a+*(a+1),结果为第一个元素与第二个元素相加。
int nums[5]={0,1,2,3,4};
int *a=nums;
(2)地址运算:通过a+i的方式.指针会指向a的下i个地址。
int nums[5]={0,1,2,3,4};
int *a=nums;
a=a+2;
printf("%d ",*a);
结果输出2。