尽管程序设计中不提倡使用goto语句,但是有的时候为了简化代码,难免会使用到goto。下面我要讨论的这个陷阱C语言程序中不会遇到,反而C++中稍不注意就会引起问题。
直接看以下代码:
int _tmain(int argc, _TCHAR* argv[])
{
int t1 = 1;
if (t1 >0)
{
goto __next;
}
int t2 = 5;...
分类:
编程语言 时间:
2015-04-16 17:37:46
阅读次数:
266
先上测试代码#include "stdafx.h"#include using namespace std;int _tmain(int argc, _TCHAR* argv[]){ const char* split = ";"; char* str = "Hello;world;";...
分类:
其他好文 时间:
2015-04-16 17:15:06
阅读次数:
174
在C语言中,main()函数有三种形式。
1、无参数
#include
int main(void)
{
printf("Hello World!\n");
return 0;
}
2、有两个参数
习惯上第一个参数是整型argc,保存了外部调用命令的参数个数,第二个参数是指针数组或二级指针argv,以字符串形式保存了与argc对应的参数,如下例子:
#include
...
分类:
编程语言 时间:
2015-04-16 10:24:07
阅读次数:
204
//C 实现 1 #include "stdafx.h" 2 #include "stdlib.h" 3 4 int _tmain(int argc, _TCHAR* argv[]) 5 { 6 int arr[6] ={0,5,3,4,6,2}; 7 int i,j; 8...
分类:
编程语言 时间:
2015-04-15 22:49:46
阅读次数:
164
#!/usr/bin/python
import sys,time
start = sys.argv[1]
end = sys.argv[2]
size = sys.argv[3]
def add(start,end,size):
def add1(number,size):
number[-1] += 1
if number[-1] == size:
del number...
分类:
编程语言 时间:
2015-04-14 21:37:29
阅读次数:
195
通过字符串数组实现两个大数相加 1 #include 2 #include 3 #include 4 5 //大数的最大位数 6 #define MAX 100 7 8 //和的最大位数 9 #define N 10110 11 int main(int argc,char *argv[])12.....
分类:
其他好文 时间:
2015-04-14 16:27:32
阅读次数:
137
今天看到《C++Primer》上写*p++等价于先运算p++然后再进行解引用计算,想了一会儿,又去网上查了查,不过发现说法不一,还有争论得不可开交的...
于是,本人默默的打开了VS...
还是亲测一下最好
#include "stdafx.h"
#include
using namespace std;
int _tmain(int argc, _TCHAR* argv[])
{
...
分类:
其他好文 时间:
2015-04-13 20:56:32
阅读次数:
123
相关函数表头文件
#include
定义函数
int getopt(int argc,char * const argv[ ],const char * optstring);
函数说明
该函数的argc和argv参数通常直接从main()的参数直接传递而来。optstring是选项字母组成的字串。如果该字串里的任一字符后面有冒号,那么这个选项...
分类:
编程语言 时间:
2015-04-13 16:40:14
阅读次数:
171
最早是在MCU中使用C语言,MCU中的main函数没有参数。后来在PC上面使用C语言,一般教程都写的是main函数有2个参数:int main(int argc, const char **argv)这个应该大家都很熟悉了。今天看到main函数有3个参数,所以做下笔记:#include int ma...
分类:
其他好文 时间:
2015-04-13 16:04:27
阅读次数:
144
1 启动在iOS系统中,由main函数启动默认调用了AppControllermain.mNSAutoreleasePool* pool = [[NSAutoreleasePoolalloc]init];intretVal =UIApplicationMain(argc, argv,nil,@"Ap...
分类:
其他好文 时间:
2015-04-13 14:30:09
阅读次数:
125