C语言
文章平均质量分 68
ericson920
这个作者很懒,什么都没留下…
展开
-
fscanf的用法
fscanf用法 int fscanf(FILE *stream, char *format,[argument...]);参数format,用正则表达式来定义要提取字符串的相应信息。通过fscanf读取data.txt文档中的用户数据,并且在控制台显示出来data.txt数据如下: #include#include #include int main(){原创 2013-03-07 10:55:58 · 2518 阅读 · 0 评论 -
c语言也能干大事之向数据库存入数据
用C语言连接mysql数据库,连接数据库的框架代码是如鹏网的板书中获得的,本例实现了从本地文件中读取数据存入mysql数据库的功能。本地数据如下: 将数据按用户名、密码的形式存入test数据库中的user表里面。具体实现代码:#define LOGIN_TIMEOUT 30#define MAXBUFLEN 255#define CHECKDBSTMTERROR(h原创 2013-03-07 16:12:39 · 1612 阅读 · 0 评论 -
C语言学习之自增/自减运算
自增1运算符记为“++”,自减1运算符记为“--”,都具有右结合性。例子定义变量a、b、c和i,初始化a和i,接着赋值b、c,输出a、b、c,最后输出i的各种自增自减结果代码#include #include "conio.h"int main(){ int a = 5, b, c; int i = 10; b = a++; c = ++b;原创 2013-04-11 11:36:27 · 1615 阅读 · 0 评论 -
C语言学习之数列求和
计算1+1+2+1+2+3+1+2+3+4+.....+1+2+3+4+……+n的值。代码#include #include "conio.h"int main(){ int sum2 = 0; int n = 0; printf("please enter the largest number of this caculate: \n"); sc原创 2013-04-11 14:22:06 · 4557 阅读 · 0 评论 -
C语言学习之求解二维数组的最大/最小元素
在n行n列的二维数组中寻找最大数和最小数。遍历数组,用新遇到的最大数/最小数替换原始最大最小数变量值。代码#include #include #define ROW 3#define COL 4void main(){ int a[ROW][COL]; int i,j; int r_max,r_min; //输入A矩阵 printf("please enter原创 2013-04-15 11:41:43 · 2893 阅读 · 0 评论 -
C语言学习之用二维数组实现矩阵转置
输入3*4矩阵转置为4*3矩阵,并输出结果。代码#include #include #define ROW 3#define COL 4void main(){ int a[ROW][COL],b[COL][ROW]; int i,j; //输入A矩阵 printf("please enter the element of matrixA:%d*%d\n",ROW,原创 2013-04-15 10:12:40 · 11613 阅读 · 0 评论 -
C语言学习之对数组元素初步排序
对一个一维整形数组进行排序,使其元素的顺序为0在中间,负数在前面,正数在后面。代码#include #include void rest(int a[],int n){ int i,j,high,low,temp; high = n-1; low = 0; for (i = 0;i<=high;) { //如果a[i]<0,则与第一个元素交换并将第一个元素指向第二个。原创 2013-04-16 09:42:45 · 872 阅读 · 0 评论