如何把代码复制到codeblocks里_code blocks使用方法总结

下载和安装:

tips:同一个版本有多个安装文件,官网上有对于各个文件的简要介绍。最好选择 mingw-setup 。

之后按照下图配置下编译器和调试器就可以使用了。

bca3970908af470185ff79da8118131a.png

1.基本使用:

2.一定要建项目才能编译运行代码吗?

不一定,也可以直接新建文件,直接运行。

如何管理这些未纳入项目的文件?通过左侧Management面板,切换到Files标签,可以对未纳入项目的文件进行管理。

建议:对需要调试的代码建立项目,对代码文件较少的小项目使用文件方式进行管理。

3.怎么调试?

一定要在项目中才能调试。调试时相关的文件及文件夹名称中最好全是英文。

注0:项目目录名、文件名中不能有中文、空格等。

注1:调试时,若想查看某个变量的值,选取菜单“Debug-Debugging windows-Watches”打开变量内容查看窗口。

注2:启动调试时提示“没有指定调试器”。可进行如下设置:点击菜单栏的debug->Active debuggers->GDB/GCB

注3:启动调试时提示“要设置gdb程序”。原因:未设置好Debugger的执行路径。解决方法:菜单Settings-Debuggers-Default,然后在Executable path中选择gdb程序,比如选择了C:\Program Files (x86)\CodeBlocks\MinGW\bin路径下的gdb32.exe。

4.在项目中如何单独运行执行程序文件?

已经建立了一个工程(如HelloWorld),包含了main.cpp(里面有main方法),并编译运行成功。这时希望在该项目中另外建立一个包含main方法的main1.cpp。运行时提示:一个项目中不能包含多个包含main方法的文件。

原因:一个CodeBlocks项目中,只能有一个入口文件(包含main函数的文件)。

解决方案:另外建一个项目,或者参考下方的解答5。

5.确实想要单独运行指定程序文件,怎么办?

不建项目,以文件夹的方式进行管理。

具体方式:通过左侧Management面板,切换到Files标签以文件夹的方式管理一个目录下的多个代码文件。然后就可以启动指定程序文件。但不能进行调试也无法享受到代码提示功能。

建立项目,然后通过右键点击项目中文件,选择Remove file from project将文件从项目中移除(非删除)。然后右键点击项目,选择Add files将需要运行的包含main函数的文件添加到该项目中。

6.左侧项目面板(Management)没有了,怎么办?

菜单:View-Manager

或者按Shfit+F2

7.明明修改了代码或者新增了代码文件,运行的时候还是上一次运行的结果

可能的原因:

直接点击了运行(Ctrl+F10)。如果涉及到的相关代码没有改变,会调用上次成功运行的程序。解决方法:构建并运行(Build and Run, F9)整个项目。

如果是新增了代码文件,却无法运行。有可能该文件并没有纳入到当前项目中。可以先关闭当前项目(右键点击项目,选择Close project)。然后再编译运行该文件。

其他技巧:

格式化代码:右键点击源文件(可以在编辑框或者左侧面板的文件上面右击),选择Format this file (AStyle)。

快速完成代码框架:输入for,然后按ctrl+J即可自动生成for循环框架。支持的其他常用缩写包括while、whileb、if、ife、ifei、ifb、swith、struct、forb、class、guard(头文件定义时使用)等等。

快速找到函数定义::右侧单击函数,选择Find Implementation..

动态缩放编辑器内字体:ctrl+鼠标滚轮或者ctrl+小键盘的加号/减号。

常用快捷键:Ctrl+F9(Build,编译与链接)、F9(Build and Run,编译、链接与运行)。Ctrl+Shift+C (注释选中代码)、

Ctrl+Shift+X(取消注释高亮代码)。Ctrl+Shift+L(删除当前行)、Ctrl+L(剪切当前行)、Ctrl+D(复制当前行)。

-------------------以上复制粘贴于https://www.cnblogs.com/zhrb/p/8513351.html-----------------

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
从 Windows 3.0 SDK 发掘的资源,英文原版 + HTML版本 Microsoft Codeview and Utilities User's Guide Microsoft(R) CodeView(R) and Utilities User's Guide Version 2.3 for MS(R) OS/2 and MS-DOS(R) Operating Systems MICROSOFT CORPORATION Information in this document is subject to change without notice and does not represent a commitment on the part of Microsoft Corporation. The software described in this document is furnished under a license agreement or nondisclosure agreement. The software may be used or copied only in accordance with the terms of the agreement. It is against the law to copy the software on any medium except as specifically allowed in the license or nondisclosure agreement. No part of this manual may be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying and recording, for any purpose without the express written permission of Microsoft. (c)Copyright Microsoft Corporation, 1987, 1989. All rights reserved. Simultaneously published in the U.S. and Canada. Printed and bound in the United States of America. Microsoft, MS, MS-DOS, XENIX, and CodeView are registered trademarks of Microsoft Corporation. AT&T is a registered trademark of American Telephone and Telegraph Company. Eagle is a registered trademark of Eagle Computer, Inc. IBM is a registered trademark of International Business Machines Corporation. Intel is a registered trademark of Intel Corporation. Lotus is a registered trademark of Lotus Development Corporation. Tandy is a registered trademark of Tandy Corporation. Document No. LN0801A-500-R00-0889 Part No. 07824 10 9 8 7 6 5 4 3 2 1 %@CR:MCVTOC00@% Table of Contents Introduction New Features of the CodeView(R) Debugger About this Manual Document Conventions Part 1 The CodeView Debugger Chapter 1 Getting Started 1.1 Restrictions 1.2 The CodeView Environment 1.3 Preparing Programs for the CodeView Debugger 1.3.1 Programming Considerations 1.3.2 CodeView Compile Options 1.3.3 CodeView Link

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值