如何用visual c++6.0进行多文件编程?

州科信息网 2023-02-26 17:23 编辑:admin 275阅读

一、如何用visual c++6.0进行多文件编程?

用VC++6.0编程,注意三点:

1、用Win32控制台程序建立项目。

2、添加头文件#include stdafx.h

3、要想执行窗口不一闪而过,可以用如下方法:添加头文件#include <conio.h> ,最后添加语句getch();

二、Shell编程:批量文件名称字符替换(实现源码+注释)

y:root:/tmp/file> ls -ltr

total 5

drwxr-xr-x 3 root root 640 Dec 12 11:53 ..

-rwxr-xr-x 1 root root 243 Dec 12 12:02 chgname

-rw-r--r-- 1 root root   0 Dec 12 12:02 a9.txt

-rw-r--r-- 1 root root   0 Dec 12 12:02 a88.txt

-rw-r--r-- 1 root root   0 Dec 12 12:02 a2.txt

-rw-r--r-- 1 root root   0 Dec 12 12:02 a100.txt

-rw-r--r-- 1 root root   0 Dec 12 12:02 a1.txt

drwxr-xr-x 2 root root 192 Dec 12 12:02 .

y:root:/tmp/file> ./chgname

a1.txt->a[1].txt

a100.txt->a[100].txt

a2.txt->a[2].txt

a88.txt->a[88].txt

a9.txt->a[9].txt

y:root:/tmp/file> ls -ltr

total 5

drwxr-xr-x 3 root root 640 Dec 12 11:53 ..

-rwxr-xr-x 1 root root 243 Dec 12 12:02 chgname

-rw-r--r-- 1 root root   0 Dec 12 12:02 a[9].txt

-rw-r--r-- 1 root root   0 Dec 12 12:02 a[88].txt

-rw-r--r-- 1 root root   0 Dec 12 12:02 a[2].txt

-rw-r--r-- 1 root root   0 Dec 12 12:02 a[1].txt

-rw-r--r-- 1 root root   0 Dec 12 12:02 a[100].txt

drwxr-xr-x 2 root root 208 Dec 12 12:02 .

y:root:/tmp/file> cat chgname 

#!/bin/bash

ls -1 --color=never a*.txt | awk '/^a[0-9]+\.txt$/{

    cmd=mv  $0  \47 gensub(/^a([0-9]+)\.txt$/, a\\[\\1\\].txt, , $0) \47

    cmd | getline

    close(cmd)

    print $0 -> gensub(/^a([0-9]+)\.txt$/, a\\[\\1\\].txt, , $0)

}'

 源码解释:

ls -1 --color=never a*.txt 列出所有符合条件文件然后通过管道|传输给awk

awk根据输入重组系统命令mv a1.txt 'a[1].txt'然后通过getline执行

命令执行完毕close(cmd)...

这个做法比较简单直接,如果使用while loop就比较麻烦一点点,如果你一定要while也是可以做到的。

三、TXT文件如何编程批量删除含某些字符的字符串

Windows的自带的记事本,打开TXT,在菜单[编辑]-->[替换],将要去掉的字符输出查找内容这一栏,替换为这一栏不填,就能把这些去掉。

同样在Word里也可以,用Word打开TXT,在编辑中也有替换这个功能。

如果要删除文件中所有<a

href='xxxxxx'>这样的,可以在Word中打开这个文件,进入替换功能(按Ctrl+H),在查询内容这一栏写:<a

href='*'>,注意中间是单引号

星号

单引号,这是通配符查询,同时点开下方的[更多]按钮,把[使用通配符]选中。

四、求高手教我怎么用多个文件的形式编写C++程序

你刚学C++吧,C++文件分为头文件(.h)和源文件(.cpp),头文件是不能编译的,只编译源文件。编写C++程序时一般情况下要首先新建一个工程,然后新建一些文件加到工程中,编译工程时编译器就会编译所有的源文件了。

你可以先新建工程test

加入point.cpp point.h test.cpp

在point.cpp中#includepoint.h

再编译工程test就OK了