C语言结构体数组应用之选票系统

首先介绍几个字符串常用API:

使用之前加入头文件#include ,#include

malloc(开辟):函数原型  void *malloc(size_t size)
             C库函数 void *malloc(size_t size) 分配所需的内存空间,并返回一个指向它的指针。

strcpy(字符串复制):strcpy(stu.name,"zgl");

strcmp(字符串对比):int strcmp(const char *s1,const char *s2);
             若str1=str2,则返回零;若str1str2,则返回正数

 

memset(清除):函数原型 void *memset(void *str, int c, size_t n)

 

选票系统代码示例:

#include 
#include 

struct Xuanmin
{
        char name[32];
        int ticket;
};

int main()
{
        int len;
        int i;
        int j;
        int waiver = 0;
        int mark;
        char tempname[32];

        struct Xuanmin xm[3];
        struct Xuanmin max;

        len = sizeof(xm)/sizeof(xm[1]);
        for(i=0;i

编译结果:

C语言结构体数组应用之选票系统_第1张图片

 

你可能感兴趣的:(C语言学习笔记,c语言)