Computing.Net > Forums > Programming > error C2448: '' : function

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

error C2448: '' : function

Reply to Message Icon

Name: czechswim
Date: July 8, 2004 at 18:05:30 Pacific
OS: win 2000
CPU/Ram: Pentium 4, 524 ram
Comment:

I am trying to compile c program with visual c++, but am getting this error:
sampler_50_50_dbl.cpp(41) : error C2065: 'random_seed' : undeclared identifier
sampler_50_50_dbl.cpp(42) : error C2448: '<Unknown>' : function-style initializer appears to be a function definition
sampler_50_50_dbl.cpp(42) : fatal error C1004: unexpected end of file found


can you help?
following is my code: (it should split a file into two randomly selected parts)

typedef double *renglon_fold;

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <ctype.h>
#include <time.h>
#include <stdlib.h>
#define MaxItem total_trn

int matriz[2];
renglon_fold *matriz_da_or;
int tiempo;
time_t tiem;
int num_trn;
int maxstring;
double *oldrand; /* array used in random no. generator */
int jrand; /* counter in random number generator */
double randomseed; /* random seed */

void advance_random()
/* Create next batch of 55 random numbers */
{
register int j;
double new_random;

for(j = 0; j < 24; j++) {
new_random = oldrand[j] - oldrand[j+31];
if(new_random < 0.0)
new_random = new_random + 1.0;
oldrand[j] = new_random;
}
for(j = 24; j < 55; j++) {
new_random = oldrand [j] - oldrand [j-24];
if(new_random < 0.0)
new_random = new_random + 1.0;
oldrand[j] = new_random;
}
}

void warmup_random(random_seed)
double random_seed;
/* Get random off and runnin */
{

register int i, j;
double new_random, prev_random;
void advance_random();

oldrand[54] = random_seed;
new_random = 0.000000001;
prev_random = random_seed;
for(j = 1 ; j <= 54; j++) {
i = (21 * j) % 54;
oldrand[i] = new_random;
new_random = prev_random-new_random;
if(new_random < 0.0)
new_random = new_random + 1.0;
prev_random = oldrand[i];
}
advance_random();
advance_random();
advance_random();
jrand = 0;
}

double random()
/* Fetch a single random number between 0.0 and 1.0 - Subtractive Method */
/* See Knuth, D. (1969), v. 2 for details */
{
void advance_random();

jrand++;
if(jrand >= 55) {
jrand = 1;
advance_random();
}
return(oldrand[jrand]);
}

int rnd(low, high)
int low, high;
/* Pick a random integer between low and high */
{
int i;
double random(), t;

if (low >= high)
i = low;
else {
t = (random() * (high - low + 1)) + low;
i = (int) t;
if(i > high)
i = high;
}
return(i);
}

void randomize(randomseed)
double randomseed;
/* Get seed number for random and start it up */
{
register int j;

oldrand = (double *)malloc(55 * sizeof(double));
do {
for (j = 0; j <= 54; j++)
oldrand[j] = 0.0;
jrand=0;
} while ((randomseed < 0.0) || (randomseed > 1.0));
warmup_random(randomseed);
}

void shuffle(matriz,no_elem)
renglon_fold *matriz;
int no_elem;
{
double *t;
int i, j, which_r;

if(!(t=(double *)malloc((maxstring) * sizeof(double))))
printf("error \n");
for(i=0;i<no_elem;i++){
which_r = rnd(i,no_elem-1);
for (j=0;j<maxstring;j++)
t[j] = matriz[which_r][j];
for (j=0;j<maxstring;j++)
matriz[which_r][j] = matriz[i][j];
for (j=0;j<maxstring;j++)
matriz[i][j] = t[j];
}
free(t);
}

void inicializa_todo()
{
register int i;

if(!(matriz_da_or=(renglon_fold *)malloc(num_trn * sizeof(renglon_fold))))
printf("error \n");
for(i=0;i<num_trn;i++)
if(!(matriz_da_or[i]=(double *)malloc((maxstring) * sizeof(double))))
printf("error \n");
}

void cal()
{
tiem = time(0);
tiempo = (int) tiem%num_trn;
randomize((float)tiempo/2147483648.0);
}

void lee_datos_trn21(data_file)
char *data_file;
{
FILE *table;
long init;

table = fopen(data_file,"rd");
init = ftell(table);
fseek(table, 0, SEEK_END);
num_trn = ftell(table);
fseek(table, init, SEEK_SET);
num_trn = num_trn / (sizeof(double) * maxstring);
printf("num_trn %i \n",num_trn);
if (table != NULL)
fclose(table);
}

void lee_datos_trn_or(data_file,ctrn)
char *data_file;
int ctrn;
{
FILE *table;
int i;

table = fopen(data_file,"rb");
for(i=0; i<ctrn; i++){
if (fread(matriz_da_or[i], sizeof(double), (size_t) maxstring, table) !=
maxstring)
printf("Error inputing record from file.\n");
}
if (table != NULL)
fclose(table);
}

void escribeu(matriz,root_name,sample)
renglon_fold *matriz;
char *root_name;
double sample;
{
int i,j ;
FILE *trn, *tst;
int how_many_trn;
char data_trn[50], data_test[50];
double *result;

data_trn[0] = '\0';
data_test[0] = '\0';
strcpy(data_trn,root_name);
strcpy(data_test,root_name);
strcat(data_trn,"_train.dbl");
strcat(data_test,"_test.dbl");
trn = fopen(data_trn,"wb");
how_many_trn = num_trn/2;
if(!(result=(double *)malloc((maxstring) * sizeof(double))))
printf("error in result creation \n");
for(i=0;i<how_many_trn;i++){
for(j=0;j<maxstring;j++)
result[j] = matriz_da_or[i][j];
if(!(fwrite(result,sizeof(double),(size_t)(maxstring),trn)))
printf("error during dumping result \n");
}
if (trn != NULL)
fclose(trn);
tst = fopen(data_test,"wb");
for (i=how_many_trn;i<num_trn;i++){
for(j=0;j<maxstring;j++)
result[j] = matriz_da_or[i][j];
if(!(fwrite(result,sizeof(double),(size_t)(maxstring),tst)))
printf("error during dumping result \n");
}
if (tst != NULL)
fclose(tst);
}

void sample(matriz,root_name,sample)
renglon_fold *matriz;
char *root_name;
double sample;
{
shuffle(matriz,num_trn);
shuffle(matriz,num_trn);
escribeu(matriz,root_name,sample);
}

void main (argc, argv)
int argc;
char *argv[];
{
if (argc != 4)
{
printf("\n This program is designed to read a Binary data file (each field is a number but in binary (double) format)");
printf("\n shuffle it and dump 2 equal-sized files. One file is supposed to be used as a ");
printf("\n Training file and the other as a test file.");
printf("\n");
printf("\n Usage is as follows:");
printf("\n sampler_50_50_dbl Input_file Number_of_columns Root_name");
printf("\n Input_file is the name of the input file (binary coded) ");
printf("\n Number_of_columns represents the actual number of columns of the Input_file (icluding id_col and ch_noch col.)");
printf("\n Root_name represents the root name of the output files. For example if root name is MSN_r9 ");
printf("\n then, at the end there will be two files MSN_r9_train.dbl and MSN_r9_test.dbl");
printf("\n");
exit(1);
}

maxstring = atoi(argv[2]);
lee_datos_trn21(argv[1]);
cal();
inicializa_todo();
lee_datos_trn_or(argv[1],num_trn);
sample(matriz_da_or,argv[3]);
}



Sponsored Link
Ads by Google

Response Number 1
Name: Gargamel
Date: July 11, 2004 at 19:30:15 Pacific
Reply:

I didn't look in too deep, but it seem that removing the ";" at the end of line 42 should solve it. Let me know if not.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: error C2448: '' : function

error C2448: function-style ini.. www.computing.net/answers/programming/error-c2448-functionstyle-ini/19386.html

Error message C++ www.computing.net/answers/programming/error-message-c/14103.html

Compile error C++ www.computing.net/answers/programming/compile-error-c/11983.html