看看这个程序,指针和循环中的n声明后怎么用的?只有两个问题哦~

来源:百度知道 编辑:UC知道 时间:2024/06/17 14:21:17
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>

bool StrIn(char **);
void StrSort(const char *[] , int);
void swap(void **pl, void **p2);
void StrOut (char *[] , int);

const size_t BUFFER_LEN = 256;
const size_t NUM_P = 50;

int main(void)
{
char *pS[NUM_P];/*列阵为了语句的指针*/
int count = 0;/*读取的语句的字数*/

printf("\n输入一个成功的行,按“回车”在每行的结束。\n只是按“回车”在最后\n");

for (count = 0; count < NUM_P ; count++)/*最大字数为NUM_P的语句*/
if (!StrIn(&pS[count]))/*读取一条语句*/
break;/*停止输入在0返回*/

StrSort(pS, count);/*储存语句*/
StrOut(pS,count);/*输出语句*/
return 0;
}

bool StrIn(char **pString)
{
char buffer[BUFFER_LEN];

if (gets(buffer) == NULL)/*太长?*/
{
printf("\n错误在读取数据。\n");
exit(1);/*错误

char *ptemp = NULL;/
这个变量貌似没用,定义以后没有使用

char **里的**表示指针的指针
譬如:
char a='a';
char *pa=&a;
char **ppa=&pa;
那么
printf("%p",*ppa);输出pa的值,是个地址
printf("%c",**ppa);输出的是'a',是个字符

n是表示参与函数运算的数组p的元素个数