C Language Learning (1)-Environment configuration

Source: Internet
Author: User
Tags gtk

Written in front of the words, the article is to see a set of teacher Yang's video, some of the notes made, while reading and writing, and then thank Mr. Yang.

1. The pitfalls to avoid before learning C

Myth One: C + + is an upgraded version of C; C # is an upgraded version of C + +

Myth Two: C + + is Visual C + +

Myth Three: MFC is a must-learn "advanced technology"

2. Notes on development tools

2.1 Editor (Complier): compilation is the translation process from source code to object code (machine language) that can be executed directly by the computer. The compiler for C language is: Gcc,msc++complier

Extensions: The execution of C # code is compiled two times, first compiled into intermediate language (IL) through the C # compiler, and the second compilation occurs when the EXE file generated by C # code is executed, and the instant compiler (JIT) is called to generate machine language that the machine recognizes.

2.2 Integrated development tools (IDE): The IDE generally has the following features: keyword highlighting, code automatic display, code formatting

3.GCC compilation of the first C program

Introduction to 3.1GCC

Use of 3.2GCC

First step: Download the gcc file. Put the downloaded GCC file into a directory that does not exist in the Chinese and Spaces folder.

Write the following code, named T1.c, to save the ABC folder under the E disk.

#include <stdio.h>int  main () {    printf (" hello ");     return 0 ;}

Note: Code save format to ANSI, otherwise Chinese will appear garbled.

Step Two: open cmd, enter the t1.c folder, run the compilation process, execute exe

4.EditPlus Build GCC development environment

Found every time you compile a file, you have to write a lot of duplicate code, the following describes a editplus to build a GCC build environment

Download EditPlus, and install, open. Then do the following:

Tool---"Configuring User Information---" Tool Group 1---Add tool---"Application

Such as:

4.1 Creating "GCC compilation"

Menu text: The name of the operation, its own definition

Command: Represents the program to be executed, writes the full path of the Gcc.exe

Parameter: The argument that the executing program is passing to Gcc.exe: $ (FileName)-O $ (filenamenoext). exe

Initial directory: Select "file directory", equivalent to CMD in the CD to. C folder

Action: Select "Capture Output"

Save: Select "Current file, all open files"

The interface is as follows:

Here's how to set the shortcut keys:

Tool---Shortcut---type---tool---user tool 1---New shortcut key---assignment

4.2 Creating "gcc run"

4.3 running c programs with EditPlus

1. Write the t1.c code in EditPlus, then click GCC Compile in the tool, run with GCC, and then see the results at the bottom

C language can not only write the console program, but also to make a variety of UI interface, the following c a GUI

5. Writing the first GTK program

Introduction of 5.1GTK:

Configuration of 5.2GTK:

Download the GTK and save it to the appropriate folder and configure the environment variables.

5.3GTK for use in EditPlus:

Create GTK Compilation

Configuration of the parameters:

The F in If:\gtk\include is for GTK in the F-disk;

$ (FileName)-w-o $ (filenamenoext). exe-IF: \gtk\include-IF: \gtk\include\gtk-3.0-IF: \gtk\include\cairo-IF: \GTK\INCLUDE\GDK-IF: \gtk\include\glib-2.0-IF: \gtk\lib\glib-2.0\include-IF: \gtk\include\pango-1.0-IF: \gtk\include\atk-1.0-IF: \gtk\include\gdk-pixbuf-2.0-lf:\gtk\lib-lgtk-win32-3.0-lgobject-2.0-lglib-2.0-lgdk-win32-3.0-lgdk_pixbuf-2.0-lcairo–mwindows

Enter the following code in EditPlus:

#include <stdio.h>#include<gtk/gtk.h>//Introducing GTK FilesintMainintargcChar*argv[]) {    //initializing the GTK environment without writing an errorGtk_init (null,null); //creates a new top-level window that returns the window pointergtkwidget*window=gtk_window_new (Gtk_window_toplevel); //set the form titleGtk_window_set_title (window,"Hello"); //The program exits after the setting window is closed, otherwise it cannot be seen, but the process is still there; GCC cannot be compiled at this timeG_signal_connect (window,"Destroy", gtk_main_quit,null);//    //Display windowgtk_widget_show (window); //start the message loop, no program will flash back, gtk_main generally do not write codeGtk_main (); return 0;}

After running

The first day to write here, later think of what, and then slowly modify. It's really hard to find out what you know and write it down.

C Language Learning (1)-Environment configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.