• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ read_array函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中read_array函数的典型用法代码示例。如果您正苦于以下问题:C++ read_array函数的具体用法?C++ read_array怎么用?C++ read_array使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了read_array函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: fopen

void Vectorizer::load_data(const char* filename)
{
  FILE* f = fopen(filename, "rb");
  if (f == NULL) error("Could not open %s for reading.", filename);
  lock_data();

  struct { char magic[4]; int ver; } hdr;
  if (fread(&hdr, sizeof(hdr), 1, f) != 1)
    error("Error reading %s", filename);

  if (hdr.magic[0] != 'H' || hdr.magic[1] != '2' || hdr.magic[2] != 'D' || hdr.magic[3] != 'V')
    error("File %s is not a Hermes2D Vectorizer file.", filename);
  if (hdr.ver > 1)
    error("File %s -- unsupported file version.", filename);

  #define read_array(array, type, n, c, what) \
    if (fread(&n, sizeof(int), 1, f) != 1) \
      error("Error reading the number of " what " from %s", filename); \
    lin_init_array(array, type, c, n); \
    if (fread(array, sizeof(type), n, f) != n) \
      error("Error reading " what " from %s", filename);

  read_array(verts, double4, nv, cv, "vertices");
  read_array(tris,  int3,    nt, ct, "triangles");
  read_array(edges, int3,    ne, ce, "edges");
  read_array(dashes, int2,   nd, cd, "dashes");

  find_min_max();
  unlock_data();
  fclose(f);
}
开发者ID:FranzGrenvicht,项目名称:hermes,代码行数:31,代码来源:linear3.cpp


示例2: Resize

void Wf_return::read(istream & is){
  int nfunc, nst;
  string dummy;
  is >> dummy >> nfunc;
  if(dummy != "nfunc") error("expected nfunc, got ", dummy);
  is >> dummy >> nst;
  Resize(nfunc, nst);
  is >> dummy >> is_complex;
  
  is >> dummy; read_array(is, nfunc, nst, amp);
  is >> dummy; read_array(is, nfunc, nst, phase);
  is >> dummy; read_array(is, nfunc, nst, cvals);
}
开发者ID:WagnerGroup,项目名称:PK_ExperimentalMainline,代码行数:13,代码来源:Wf_return.cpp


示例3: main

void main()
{
	int a[201], n;

	clrscr();

	// se citeste sirul
	n = read_array(a);

	// daca a aparut o eroare la citirea datelor se iese din program
	if (n == -1)
	{
		printf("Eroare la citirea datelor!");
		getch();
		exit(1);
	}

	// se apeleaza algoritmul de sortare
	binary_insertion_sort(a, n);

	printf("\ncomparatii: %d\natribuiri: %d\n\nSirul ordonat: ", comp, atr);

	// se tipareste sirul sortat
	print_array(a, n, 1);
}
开发者ID:bdumitriu,项目名称:playground,代码行数:25,代码来源:lab1_02a.cpp


示例4: read_value

/* tries to read a symbol's value */
static gboolean
read_value (CtplInputStream *stream,
            CtplValue       *value,
            GError         **error)
{
  GError *err = NULL;
  gchar   c;
  
  c = ctpl_input_stream_peek_c (stream, &err);
  if (err) {
    /* I/O error */
  } else if (c == CTPL_STRING_DELIMITER_CHAR) {
    read_string (stream, value, &err);
  } else if (c == ARRAY_START_CHAR) {
    read_array (stream, value, &err);
  } else if (c == '.' ||
             (c >= '0' && c <= '9') ||
             c == '+' || c == '-') {
    ctpl_input_stream_read_number (stream, value, &err);
  } else {
    ctpl_input_stream_set_error (stream, &err, CTPL_ENVIRON_ERROR,
                                 CTPL_ENVIRON_ERROR_LOADER_MISSING_VALUE,
                                 "No valid value can be read");
  }
  if (err) {
    g_propagate_error (error, err);
  }
  
  return ! err;
}
开发者ID:antono,项目名称:ctpl,代码行数:31,代码来源:ctpl-environ.c


示例5: read_whitespace

JsonValue JsonValue::read(const std::string &json, size_t &pos)
{
	read_whitespace(json, pos);

	if (pos == json.length())
		throw JsonException("Unexpected end of JSON data");

	switch (json[pos])
	{
	case '{':
		return read_object(json, pos);
	case '[':
		return read_array(json, pos);
	case '"':
		return read_string(json, pos);
	case '-':
	case '0':
	case '1':
	case '2':
	case '3':
	case '4':
	case '5':
	case '6':
	case '7':
	case '8':
	case '9':
		return read_number(json, pos);
	case 'f':
	case 't':
		return read_boolean(json, pos);
	default:
		throw JsonException("Unexpected character in JSON data");
	}
}
开发者ID:ARMCoderCHS,项目名称:ClanLib,代码行数:34,代码来源:json_value.cpp


示例6: main

void main()
{
	//Сохраняем текущие параметры консоли
	hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	CONSOLE_SCREEN_BUFFER_INFO csbi;
	if (GetConsoleScreenBufferInfo(hConsole, &csbi))
		currentConsoleAttr = csbi.wAttributes;

	//Объявляем массив
	static int arr[MAX_SIZE][MAX_SIZE];

	//Читаем с клавиатуры размер матрицы
	size_t n;
	printf(Rus("Введите размер матрицы (%d...%d). N: "), MIN_SIZE, MAX_SIZE);
	do
	{
		n = (size_t)read_int(stdin);
		if (n < MIN_SIZE || n > MAX_SIZE)
			printf(Rus("Неверный размер. Размер должен быть в диапазоне "
				"от %d до %d. Повторите ввод: \n"), MIN_SIZE, MAX_SIZE);
	} while (n < MIN_SIZE || n > MAX_SIZE);

	//Заполняем матрицу
	printf(Rus("Вводите элементы массива до заполнения\n"));
	UINT8 width = read_array(arr[0], n);

	//Выводим матрицу
	print_array(arr[0], n, TASK_ZONE, width);

	//Считаем значение из задания
	UINT64 sum = func_v13(arr[0], n, TASK_ZONE);

	printf(Rus("Сумма квадратов отрицательных чисел = %d\n"), sum);
}
开发者ID:CAHbl4,项目名称:C,代码行数:34,代码来源:Home2_2.cpp


示例7: read_deps

static struct list_parse_dep
read_deps (char *s)
{
  char *save;
  struct list_parse_dep res = {0};
  for (char *depstr = strtok_r (s, "#", &save); depstr;
       depstr = strtok_r (NULL, "#", &save)) {
    char *save2;
    char *match, *portstr;
    int rule;

    rule = atoi (strtok_r (depstr, ";", &save2)) + 1;
    match = strtok_r (NULL, ";", &save2);
    portstr = strtok_r (NULL, ";", &save2);

    uint32_t ports[MAX_ARR_SIZE];
    struct arr_ptr_uint32_t nports = read_array (portstr, ports);

    struct parse_dep *tmp = xmalloc (sizeof *tmp + nports.n * sizeof *ports);
    tmp->rule = rule;
    tmp->match = array_from_str (match);
    tmp->nports = nports.n;
    memcpy (tmp->ports, ports, nports.n * sizeof *ports);

    list_append (&res, tmp);
  }
  return res;
}
开发者ID:NetSys,项目名称:sts,代码行数:28,代码来源:parse.c


示例8: main

int main() {
  int size;

  scanf("%d", &size);
  read_array(size, size);
  printf("]\n");
}
开发者ID:PoissonJ,项目名称:notes,代码行数:7,代码来源:problem5.c


示例9: begin_record

 BinaryInputStream&
 BinaryInputStream::read_record(Numeric::float64* data, int nbr) {
     begin_record();
     read_array(data, nbr);
     end_record();
     return *this;
 }
开发者ID:NickDaniil,项目名称:structured,代码行数:7,代码来源:b_stream.cpp


示例10: cf_parse_cmd_line

char* cf_parse_cmd_line(int argc, char *argv[]) {
	int c;
	CONF_ITEM *cf;


	option_index = optind = 0;
#ifdef WII
	return NULL;
#endif
	while ((c = getopt_long(argc, argv, shortopt, longopt, &option_index)) != EOF) {
		//if (c != 0) {
//			printf("c=%d\n",c);
			cf = cf_get_item_by_val(c&0xFFF);
			if (cf) {
				cf->flags |= CF_SETBYCMD;
//				printf("flags %s set on cmd line\n", cf->name);
				switch (cf->type) {

					case CFT_INT:
						CF_VAL(cf) = atoi(optarg);
						break;
					case CFT_BOOLEAN:
					if (c & 0x1000)
						CF_BOOL(cf) = 0;
					else
						CF_BOOL(cf) = 1;
						break;
					case CFT_STRING:
						strcpy(CF_STR(cf), optarg);
						//printf("conf %s %s\n",CF_STR(cf),optarg);
						break;
					case CFT_ARRAY:
						read_array(CF_ARRAY(cf), optarg, CF_ARRAY_SIZE(cf));
						break;
					case CFT_ACTION_ARG:
						strcpy(CF_STR(cf), optarg);
						if (cf->action) {
							exit(cf->action(cf));
						}
						break;
					case CFT_ACTION:
						if (cf->action) {
							exit(cf->action(cf));
						}
						break;
					case CFT_STR_ARRAY:
						/* TODO */
						break;
				}
			//}
		}
	}
	cf_cache_conf();
	if (optind >= argc)
		return NULL;

	return strdup(argv[optind]);
}
开发者ID:yoyofr,项目名称:iNEOGEO,代码行数:58,代码来源:conf.c


示例11: main

int main(){
	int i,k,n,arr[50];
	printf("Enter the value of n : \t");
	scanf("%d",&n);
	printf("Enter the array : ");
	read_array(arr,n);	
	insertion_sort(arr,n);
	display_array(arr,n);
}
开发者ID:sarathsnair,项目名称:AlgoDS,代码行数:9,代码来源:InsertionSort.c


示例12: file_input

void file_input(FILE* file, char* header, char A[MAX_N], char B[MAX_N]  ){
	char buf[256];
	int a, b, num_success;
	header[0] = 0;
	do{
		fgets(buf, MAX_N, file);
		strcat(header, buf);
	} while(strcmp(buf, "\n"));
	//read the numbers
	num_success = fscanf(file, "%d %d", &a, &b);
	if (num_success < 2)
		fail("Failed to read array sizes from input string. Closing...");
	fgets(buf, 256, file);
	fgets(buf, 256, file); //array a
	read_array(buf, A, a, "A");
	fgets(buf, 256, file); //array b
	read_array(buf, B, b, "B");
};
开发者ID:FakeEmperor,项目名称:Semester03,代码行数:18,代码来源:main.cpp


示例13: main

int main(int argc, const char *argv[])
{
	int *v1, *v2, n, cont; //vetor 1, vetor 2, numero de elementos, contador;

	puts("Informe o tamanho do vetor:");
	scanf("%d", &n);	

	v1 = (malloc(sizeof(int) * n)); //alocar n endereços de memoria para o vetor 1;
	v2 = (malloc(sizeof(int) * n)); //alocar n endereços de memoria para o vetor 2;
    printf ( "Lendo o primeiro vetor...\n" );
	read_array(n, v1); //vetor 1 recebe os valores;
    printf ( "Lendo o segundo vetor...\n" );
	read_array(n, v2); //vetor 2 recebe os valores;

	printf("O produto escalar é: %d\n", produto_escalar(n, v1, v2)); // printa o retorno da função produto escalar que recebe os dois vetores e o tamanho deles e depois calcula o produto escalar.

	return 0;
}
开发者ID:jucimarjr,项目名称:pca,代码行数:18,代码来源:lista2.04.c


示例14: read_array

//Reads in the command information from the user
//Helps make the program easier to read
int menuType::readCommandInfo(commandType & tempCommand)
{
  char * temp = new char [TEMP_SIZE];   //Used to store information from the user
  int len = 0;                          //Used to 'measure' the arrays

  //Reads in the infromation from the user and stores it in the passed command  
  read_array("Command function: ", temp, TEMP_SIZE);
  len = strlen(temp);
  tempCommand.func = new char[len+1];
  strcpy(tempCommand.func, temp);
  
  read_array("Defined rules: ", temp, TEMP_SIZE);
  len = strlen(temp);
  tempCommand.rules = new char[len+1];
  strcpy(tempCommand.rules, temp);
  
  delete [] temp;
}
开发者ID:Nrpickle,项目名称:CS163,代码行数:20,代码来源:menu.cpp


示例15: fopen

      void Orderizer::load_data(const char* filename)
      {
        FILE* f = fopen(filename, "rb");
        if (f == NULL) error("Could not open %s for reading.", filename);
        lock_data();

        struct { char magic[4]; int ver; } hdr;
        if (fread(&hdr, sizeof(hdr), 1, f) != 1)
          error("Error reading %s", filename);

        if (hdr.magic[0] != 'H' || hdr.magic[1] != '2' || hdr.magic[2] != 'D' || hdr.magic[3] != 'O')
          error("File %s is not a Hermes2D Orderizer<Scalar> file.", filename);
        if (hdr.ver > 1)
          error("File %s -- unsupported file version.", filename);

#define read_array(array, type, n, c, what) \
  if (fread(&n, sizeof(int), 1, f) != 1) \
  error("Error reading the number of " what " from %s", filename); \
  lin_init_array(array, type, c, n); \
  if (fread(array, sizeof(type), n, f) != (unsigned) n) \
  error("Error reading " what " from %s", filename);

        read_array(verts, double3, nv, cv,  "vertices");
        read_array(tris,  int3,    nt, ct,  "triangles");
        read_array(edges, int3,    ne, ce,  "edges");
        read_array(lvert, int,     nl, cl1, "label vertices");

        lin_init_array(lbox, double2, cl3, nl);
        if (fread(lbox, sizeof(double2), nl, f) != (unsigned) nl)
          error("Error reading label bounding boxes from %s", filename);

        int* orders = new int[nl];
        if (fread(orders, sizeof(int), nl, f) != (unsigned) nl)
          error("Error reading element orders from %s", filename);

        lin_init_array(ltext, char*, cl2, nl);
        for (int i = 0; i < nl; i++)
          ltext[i] = labels[H2D_GET_H_ORDER(orders[i])][H2D_GET_V_ORDER(orders[i])];

        find_min_max();
        unlock_data();
        fclose(f);
      }
开发者ID:Amuthan,项目名称:hermes-dev,代码行数:43,代码来源:orderizer.cpp


示例16: main

int main(int argc, char* argv[]) {
	A2 A = create_array();  
	write_array(A);

    std::cout << ((read_array(A) == 1) ? "ok" : "error") << std::endl;
    std::cout << ((A.rsum(N - 1) == 1) ? "ok" : "error") << std::endl;
    std::cout << ((A.csum(M - 1) == 1) ? "ok" : "error") << std::endl;

    return 0;
} // main
开发者ID:asrathor,项目名称:CSE-250,代码行数:10,代码来源:a2.cpp


示例17: read_array

int menuType::addNew(mappingType & map)
{
  int status = 0;

  dataType newData;


  //Name
  newData.name = new char[TEMP_SIZE];
  read_array("Name: ", newData.name, TEMP_SIZE);
  //Type
  newData.type = new char[TEMP_SIZE];
  read_array("Type: ", newData.type, TEMP_SIZE);
  //Memory Location
  newData.memoryLocation = rand() % 100000;   

  status = map.insertItem(newData);  //Insert the data into the ADT

  return status;
}
开发者ID:Nrpickle,项目名称:CS163,代码行数:20,代码来源:menu.cpp


示例18: ctache_data_create_hash

static ctache_data_t
*read_object(struct json_parser *parser)
{
	ctache_data_t *data;
	struct json_token *tok;
	char *key;
	ctache_data_t *val;
	int done = 0;
	size_t len;

	data = ctache_data_create_hash();

	while (!done) {
		tok = json_next_token(parser);
		key = strdup(tok->value.string);
		tok = json_next_token(parser);
		if (tok->type != JSON_COLON) {
			fprintf(stderr, "ERROR: Expected ':'\n");
			ctache_data_destroy(data);
			free(key);
			return NULL;
		}
		tok = json_next_token(parser);
		if (tok->type == JSON_STRING) {
			len = strlen(tok->value.string);
			val = ctache_data_create_string(tok->value.string, len);
		} else if (tok->type == JSON_BOOLEAN) {
			val = ctache_data_create_boolean(tok->value.boolean);
		} else if (tok->type == JSON_BRACE_LEFT) {
			val = read_object(parser);
		} else if (tok->type == JSON_BRACKET_LEFT) {
			val = read_array(parser);
		} else {
			fprintf(stderr, "ERROR: Expected value\n");
			ctache_data_destroy(data);
			free(key);
			return NULL;
		}
		ctache_data_hash_table_set(data, key, val);
		free(key);

		tok = json_next_token(parser);
		if (tok->type == JSON_BRACE_RIGHT) {
			done = 1;
		} else if (tok->type == JSON_COMMA) {
			done = 0;
		} else {
			fprintf(stderr, "ERROR: Expected '}'\n");
			ctache_data_destroy(data);
			return NULL;
		}
	}
	return data;
}
开发者ID:dwjackson,项目名称:ctache,代码行数:54,代码来源:json_data.c


示例19: pg_text_dec_array_helper

static VALUE
pg_text_dec_array_helper(t_pg_type *conv, char *val, int len, int tuple, int field, int enc_idx, t_pg_type_dec_func dec_func)
{
	/* create a buffer of the same length, as that will be the worst case */
	char *word = xmalloc(len + 1);
	int index = 1;

	VALUE return_value = read_array(conv, &index, val, len, word, enc_idx, tuple, field, dec_func);
	free(word);
	return return_value;
}
开发者ID:willbryant,项目名称:ruby-pg,代码行数:11,代码来源:pg_text_decoder.c


示例20: input_arr

state input_arr(void* data, void* params)
{
	cci.dwSize = 5;
	cci.bVisible = TRUE;
	SetConsoleCursorInfo(hConsole, &cci);
	system("cls");
	flush_stream(stdin);
	printf(Rus("Вводите числа и они будут записаны в массив.\n"));
	printf(Rus("Для прекращения ввода-<Enter> в начале строки.\n"));
	arr = read_array(arr, &arr_count);
	return REDRAW_ALL;
}
开发者ID:CAHbl4,项目名称:C,代码行数:12,代码来源:Exam.cpp



注:本文中的read_array函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ read_binary_file函数代码示例发布时间:2022-05-30
下一篇:
C++ read_args函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap