The blogger has just learned C language for a while, and he is not very proficient in the way of returning functions as parameters, so this small experiment is recorded.
code show as below:
/******************************************
*功能:实例了函数返回通过参数输出的实现
*作者:lml 时间:2020年4月12日18点
******************************************/
#include<stdio.h>
#include <stdlib.h>
//做两个形参,buf为输入参数,val为输出参数
int func(char *buf,int *val)
{
char *arr;
arr = buf;
*val = atoi(arr);
return 0;
}
int main(int argc, const char *argv[])
{
char buf[10]={
"123"};
int data=0;
func(buf,&data);
printf("%d\n",data);
return 0;
}
Finish.