Fastor·Breaker 2023-11-24 20:13 采纳率: 0%
浏览 1

devc++在字符串使用_T时报错

#include <bits/stdc++.h>
# include <graphics.h>
#include <tchar.h>
using namespace std;
int main(){
boxm[10].text = _T("hello");
return 0;
}

怎么办,崩溃!

  • 写回答

1条回答 默认 最新

  • CSDN-Ada助手 CSDN-AI 官方账号 2023-11-24 23:00
    关注

    【相关推荐】



    • 你可以参考下这个问题的回答, 看看是否对你有帮助, 链接: https://ask.csdn.net/questions/7503664
    • 我还给你找了一篇非常好的博客,你可以看看是否有帮助,链接:devc++中的圣诞树
    • 除此之外, 这篇博客: 首次适应算法 动态分区分配方式的模拟 C语言——课程设计实习中的 C语言源程序——建议使用Devc ++ 运行 部分也许能够解决你的问题, 你可以仔细阅读以下内容或跳转源博客中阅读:
      #include<stdio.h>
      #include<stdlib.h>
      struct nodespace{
      	int teskid;   // 作业号 
      	int begin;    // 开始地址 
      	int size;     // 大小 
      	int status;   // 状态 0代表占用,1代表空闲 
      	struct nodespace *next;  // 后指针 
      };
      void initNode(struct nodespace *p){
      	if(p == NULL){	//如果为空则新创建一个 
      		p = (struct nodespace*)malloc(sizeof(struct nodespace));
      	}
      	p->teskid = -1;
      	p->begin = 0;
      	p->size = 640;
      	p->status = 1;
      	p->next =NULL; 
      }  
      void myMalloc1(int teskid,int size,struct nodespace *node){
      	while(node != NULL){
      		if(node->status == 1){  //空闲的空间 
      			if(node->size > size){  //当需求小于剩余空间充足的情况 
      				//分配后剩余的空间 
      				struct nodespace *p = (struct nodespace*)malloc(sizeof(struct nodespace));
      				p->begin = node->begin + size;
      				p->size = node->size - size;
      				p->status = 1;
      				p->teskid = -1;
      				//分配的空间 
      				node->teskid = teskid; 
      				node->size = size;
      				node->status = 0;
      				//改变节点的连接 
      				p->next = node->next; 
      				node->next = p;
      				printf("==================================分配内存成功!==================================\n");
      				break; 
      			}else if(node->size == size){ //需求空间和空闲空间大小相等时 
      				node->teskid = teskid; 
      				node->size = size;
      				node->status = 0;
      				printf("==================================分配内存成功!==================================\n");
      				break;
      			}	
      		}
      		if(node->next == NULL){
      			printf("===============================分配失败,没有足够的空间!=============================\n");
      			break;
      		}
      		node = node->next;
      	}
      } 
      void myFree(int teskid,struct nodespace *node){
      	if(node->next == NULL && node->teskid == -1){
      		printf("================================您还没有分配任何作业!================================\n");
      	}
      	
      	while(node != NULL){
      		if(node->status == 1 && node->next->status ==0 && node->next->teskid == teskid){
      			
      			struct nodespace *q = node->next;
      			node->next = node->next->next;
      			free(q);
      			printf("==================================释放内存成功!==================================\n");
      			if(node->next->status == 1){ //下一个空间是空闲空间时 
      				node->size = node->size + node->next->size;
      				struct nodespace *q = node->next;
      				node->next = node->next->next;
      				free(q);
      				printf("==================================释放内存成功!==================================\n");
      			}
      			break;
      		}else if(node->status == 0 && node->teskid == teskid){  //释放空间和空闲空间不连续时  
      			node->status = 1;
      			node->teskid = -1;
      			if(node->next != NULL && node->next->status == 1){ //下一个空间是空闲空间时 
      				node->size = node->size + node->next->size;
      				struct nodespace *q = node->next;
      				node->next = node->next->next;
      				free(q);
      			}
      			printf("==================================释放内存成功!==================================\n");
      			break;
      		}else if(node->next == NULL){  //作业号不匹配时 
      			printf("==================================没有此作业!!==================================\n");
      			break;
      		}
      		node = node->next;
      	}
      	
      	 
      } 
      void printNode(struct nodespace *node){
      	printf("                        内存情况                        \n"); 
      	printf(" -------------------------------------------------------\n");
      	printf("| 起始地址\t结束地址\t大小\t状态\t作业号\t|\n");
      	while(node != NULL){
      		if(node->status==1){
      			printf("| %d\t\t%d\t\t%dKB\tfree\t 无\t|\n", node->begin + 1, node->begin+node->size, node->size);
      		}else{
      			printf("| %d\t\t%d\t\t%dKB\tbusy\t %d\t|\n", node->begin + 1, node->begin+node->size, node->size, node->teskid);
      		}
      		node = node->next;
      	}
      	printf(" -------------------------------------------------------\n");
      }
      void destory(struct nodespace *node){
      	struct nodespace *q = node;
      	while(node != NULL){
      		node = node->next;
      		free(q);
      		q = node;
      	}
      } 
      void menu(){
      	printf("\n"); 
      	printf("\t\t\t\t   ╭═════════════════════════════════○●○●═══╮\n");
      		printf("\t\t\t\t   │    首次适应算法的动态分区分配方式模拟      │\n");
      		printf("\t\t\t\t   ╰═══○●○●═════════════════════════════════╯\n");
      		printf("\t\t\t\t   ┌───────────────────────────────────────────-┐\n");
      		printf("\t\t\t\t   │                                            │\n");
      		printf("\t\t\t\t   │                 1. 申请内存                │\n");
      		printf("\t\t\t\t   │                                            │\n");
      		printf("\t\t\t\t   │                 2. 回收内存                │\n");
      		printf("\t\t\t\t   │                                            │\n");
      		printf("\t\t\t\t   │                 3. 查看内存情况            │\n");
      		printf("\t\t\t\t   │                                            │\n");
      		printf("\t\t\t\t   │                 4. 退出                    │\n");
      		printf("\t\t\t\t   │                                            │\n");
      		printf("\t\t\t\t   └────────────────────────────────────────────┘\n");
      		printf("\t\t\t\t\t\t  请您选择(1-4):\t");
      }
       
      int main(){
      	// node为整个空间 
      	system("color 0f");
      	//system("mode con cols=120 lines=50");
      	struct nodespace *init = (struct nodespace*)malloc(sizeof(struct nodespace));
      	struct nodespace *node = NULL;
      	initNode(init);			//初始化主链 
      	node = init; 			//指向链表头 
      	int option; 
      	int teskid;
      	int size;
      	while(1){
      		menu();		//打印想要进行的操作
      		scanf("%d",&option);
      		if(option == 1){
      			printf("请输入作业号;");
      			scanf("%d",&teskid);
      			printf("此作业申请的空间大小(KB):");
      			scanf("%d",&size);
      			myMalloc1(teskid,size,node);
      			printf("\n"); 
      			printNode(node);
      		}else if(option == 2){
      			printf("请输入作业号:");
      			scanf("%d",&teskid);
      			myFree(teskid,node);
      			printf("\n"); 
      			printNode(node);
      		}else if(option == 3){
      			printNode(node);
      		}else if(option == 4){
      			destory(node);
      			initNode(init);
      			node = init;
      			break;
      		}else{
      			printf("===========================您的输入有误,请重新输入!============================\n");
      			continue;
      		}
      	}
      return 0;
      }
      

    如果你已经解决了该问题, 非常希望你能够分享一下解决方案, 写成博客, 将相关链接放在评论区, 以帮助更多的人 ^-^
    评论

报告相同问题?

问题事件

  • 创建了问题 11月24日

悬赏问题

  • ¥15 模电中二极管,三极管和电容的应用
  • ¥15 关于模型导入UNITY的.FBX: Check external application preferences.警告。
  • ¥15 气象网格数据与卫星轨道数据如何匹配
  • ¥100 java ee ssm项目 悬赏,感兴趣直接联系我
  • ¥15 微软账户问题不小心注销了好像
  • ¥15 x264库中预测模式字IPM、运动向量差MVD、量化后的DCT系数的位置
  • ¥15 curl 命令调用正常,程序调用报 java.net.ConnectException: connection refused
  • ¥20 关于web前端如何播放二次加密m3u8视频的问题
  • ¥15 使用百度地图api 位置函数报错?
  • ¥15 metamask如何添加TRON自定义网络