小编Ahm*_*raf的帖子

如何创建一个数组来保存结构?

我被要求创建一些结构:学生,老师,课程,程序,然后制作一个数组,以容纳5个学生结构,并为数组中的学生的字段分配值,我坚持创建数组来保持结构,这是代码:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Module4Assignment
{
    class Program
    {
        //Student structure: 
        public struct Student
        {
            public Student (string name , string address , string country , string birthday , int telephone)
            {
                this.Name = name;
                this.Address = address;
                this.Country = country;
                this.Birthday = birthday;
                this.Telephone =telephone;
            }

            public string Name;
            public string Address;
            public string Country;
            public string Birthday;
            public int Telephone;
        }

        //Teacher structure:
        public struct Teacher
        {
            public Teacher(string tname, …
Run Code Online (Sandbox Code Playgroud)

c# arrays structure

1
推荐指数
1
解决办法
1748
查看次数

Strcmp()函数没有返回0

我试图使用strcmp()比较两个字符串,并且在它们相等的情况下,函数返回-1(意味着它们不相等),我不知道什么是错的.

int main()
{
char password[]={'6','6','6','6','6','6'};
char passmatch[6];
int i =0;
for(i ; i<6 ; i++)
{
    passmatch[i]='6';
}

printf("\n");
if(strcmp(password,passmatch)==0)
{
    printf("Strings are equal");
}
else
{
    printf("String are'nt equal");
}


return 0;
Run Code Online (Sandbox Code Playgroud)

}

c strcmp

1
推荐指数
1
解决办法
185
查看次数

标签 统计

arrays ×1

c ×1

c# ×1

strcmp ×1

structure ×1