项目无法运行main函数(SourceSet with name ‘main‘ not found)

新建的Android项目无法运行main函数,出现如下错误

9:52:25: Executing task 'HH.main()'...

Executing tasks: [HH.main()] in project E:\DemoC\TestDemo


FAILURE: Build failed with an exception.

* Where:
Initialization script 'C:\Users\Administrator.SC\Local\Temp\HH_main__.gradle' line: 21

* What went wrong:
A problem occurred configuring project ':app'.
> Could not create task ':app:HH.main()'.
   > SourceSet with name 'main' not found.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 0s
9:52:25: Task execution finished 'HH.main()'.

解决方案:修改.idea--->gradle.xml中添加 <option name="delegatedBuild" value="false" />重新Rebuild Project就可以

  • 2
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
好的,下面是一个可能的宿舍管理系统的main函数的示例: ``` #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_STUDENTS 100 struct Student { char name[20]; int room; }; int main() { struct Student students[MAX_STUDENTS]; int num_students = 0; while (1) { printf("\n1. Add student\n2. Remove student\n3. View all students\n4. Exit\n\n"); printf("Enter option: "); int option; scanf("%d", &option); switch (option) { case 1: { if (num_students >= MAX_STUDENTS) { printf("Error: Maximum number of students reached\n"); break; } printf("Enter student name: "); char name[20]; scanf("%s", name); printf("Enter room number: "); int room; scanf("%d", &room); struct Student new_student; strcpy(new_student.name, name); new_student.room = room; students[num_students] = new_student; num_students++; break; } case 2: { printf("Enter student name: "); char name[20]; scanf("%s", name); int found = 0; for (int i = 0; i < num_students; i++) { if (strcmp(students[i].name, name) == 0) { for (int j = i; j < num_students - 1; j++) { students[j] = students[j + 1]; } num_students--; found = 1; break; } } if (!found) { printf("Error: Student not found\n"); } break; } case 3: { printf("\n"); for (int i = 0; i < num_students; i++) { printf("%s %d\n", students[i].name, students[i].room); } break; } case 4: { printf("Exiting...\n"); exit(0); } default: { printf("Error: Invalid option\n"); break; } } } return 0; } ``` 这个main函数提供了一个简单的菜单界面,允许用户添加、删除和查看学生信息。在程序运行时,会执行这个函数
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值