今天的学习内容在我上传的资源里面
我提供下链接供参考
http://download.youkuaiyun.com/download/lsy888520/10125339
相关代码
我提供下链接供参考
http://download.youkuaiyun.com/download/lsy888520/10125339
相关代码
2.C
#include <stdio.h>
void change(int *arg1, int *arg2)
{
int temp = *arg1;
*arg1 = *arg2;
*arg2 = temp;
}
int main()
{
int a = 5, b = 9;
change(&a, &b);
printf("a = %d, b = %d\n", a, b);
return 0;
}
void change(int *arg1, int *arg2)
{
int temp = *arg1;
*arg1 = *arg2;
*arg2 = temp;
}
int main()
{
int a = 5, b = 9;
change(&a, &b);
printf("a = %d, b = %d\n", a, b);
return 0;
}
3.C
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 50
void SpaceOfStr(char *str, int *space)
{
int i;
for(i = 0; *str != '\0'; i++)
{
if(' ' == *(str++))
{
(*space)++;
}
}
}
int main()
{
int space = 0;
char s[SIZE];
char *p;
printf("input string :\n");
gets(s);
p = s;
SpaceOfStr(p, &space);
printf("space = %d\n", space);
puts(p);
return 0;
}
#include <stdlib.h>
#include <string.h>
#define SIZE 50
void SpaceOfStr(char *str, int *space)
{
int i;
for(i = 0; *str != '\0'; i++)
{
if(' ' == *(str++))
{
(*space)++;
}
}
}
int main()
{
int space = 0;
char s[SIZE];
char *p;
printf("input string :\n");
gets(s);
p = s;
SpaceOfStr(p, &space);
printf("space = %d\n", space);
puts(p);
return 0;
}
4.C
#include <stdio.h>
#define N 50
void LengthOfStr(char *str, int *length)
{
while(*(str++) != '\0')
{
(*length)++;
}
}
int main()
{
int length = 0;
char str[N], *p;
printf("input string :\n");
gets(str);
p = str;
LengthOfStr(p, &length);
printf("length = %d\n", length);
return 0;
}
#define N 50
void LengthOfStr(char *str, int *length)
{
while(*(str++) != '\0')
{
(*length)++;
}
}
int main()
{
int length = 0;
char str[N], *p;
printf("input string :\n");
gets(str);
p = str;
LengthOfStr(p, &length);
printf("length = %d\n", length);
return 0;
}