C

gis.h file


#ifndef GIS_H
#define GIS_H
#include <stdio.h>
#include <stdint.h>
#define MAX_CHAR 256

typedef struct _Index Index;
struct _Index
{
char nameAndState[MAX_CHAR];
uint32_t offset[MAX_CHAR];
Index *pointer;
};

FILE fp1;
int CommandOrder;
char
recordFileName1;
Index** hashtable;
Index* hashtableIndex;


gis.c file


#include “gis.h”
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <stdio.h>
#include <math.h>
#include <stdint.h>

File:

char *script = argv[1];
fp1 = fopen(script,“r”); //open file
fgets(target, MAX_RECORD_CHAR, fp3);
fprintf(fp2, “%d %s %s”, k, name, state);

Memory

char db_file = malloc(MAX_CHARsizeof(char));
//malloc calloc 因为需要return,或者因为出了function之后继续保存
char * str3 = (char *) malloc(1 + strlen(name)+ strlen(state) );
//要多malloc一个位置给终止符

Value

int id = atoi(char); //change char to int

Int to String:
int num = 100;
char str[25];
sprintf(str, " %d" , num);
String:

char* word1 = strtok(eachRecord,"\t"); //string中取值
strncpy(char_pointer, eachRecord, 7); //copy string
strcpy(target, source); //copy string
strcmp(a,b) //string compare(a,b 是pointer也可以 )
if(strcmp(result->Mnemonic,“add”) == 0) // ==0意味着相同
charcount = strlen(Record); //length of a char array

char* first_token = strtok(record,"\t"); //
char* second_token = strtok(NULL,"\t"); // second 用NULL means继续token这个string

strcpy(str3, name);
strcat(str3, state);
sprintf(target, “incormation %s”, source)
scanf(source, “%s %s %d” , city, state,&pop) //后面为target
//!!***!!scanf中如果是数值,一定要加&

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值