小编fal*_*n21的帖子

用指针C循环

我正在努力解决这个问题.基本上,这个function void check(char *tel, char *c)数组的第一个值必须是数字2,而其他数字必须是数字之间的数字0 and 9.如果满足条件,将打印V,否则将打印F.

#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>

void check(char *tel, char *c){

int i;

if(*tel!=2) printf("Error\n"); 
                *c='F';
                return;  //I guess this return is wrong

if(*tel==2)
    for(i=0;tel[i]<9;i++){
        if(isdigit(tel[i]));

                   else{
               printf("Error!\n");
               *c='F';
               break;
                               return;}         //this one might be in bad use too

    }
 else

 *c='V';           //having troubles here.. i'm not seeing a way to fix this
 }

 int main(){

 char number[9]={2,3,4,5,6,7,4,5,3};
 char car;


 check(number,&car);

 printf("%c \n", car); …
Run Code Online (Sandbox Code Playgroud)

c pointers function

-3
推荐指数
1
解决办法
129
查看次数

标签 统计

c ×1

function ×1

pointers ×1