Cannot Say Hello To The World Due To 'code 1'

/************************************************************
*
* Project 0: My First Program in C++
*
* Author: xxx xxxx
* Date: 18 January 2015
*
* This is the canonical first program for C++.
* Its purpose is to show that one knows how to create a program in
* one's particular programming environment.
*
************************************************************/

#include <bjarne/std_lib_facilities.h>

int main()
{
cout << "Hello, world!\n";

return 0;
}

I compiled the hello world program as my prof instructed.
then I used C+c C+c, delete 'make -k' and replaced with 'g++ -o proj0 -std=c++11 proj0.cc', choose to save the file, and it goes 'compilation exited abnormally with code 1'

note that I do all these by making SSH connection with computer in lab with a linux system

FYI, the whole thing is:

-*- mode: compilation; default-directory: "~/private/cs1/proj0/" -*-
Compilation started at Sun Jan 18 21:15:54

g++ -o proj0 -std=c++11 proj0.cc
In file included from /usr/include/c++/4.9.2/locale:41:0,
from /usr/include/c++/4.9.2/iomanip:43,
from /usr/local/include/bjarne/std_lib_facilities.h:220,
from proj0.cc:14:
/usr/include/c++/4.9.2/bits/locale_facets_nonio.h:1869:5: error: template-id do_get<> for String std::messages<char>::do_get(std::messages_base::catalog, int, int, const String&) const does not match any template declaration
messages<char>::do_get(catalog, int, int, const string&) const;
^
/usr/include/c++/4.9.2/bits/locale_facets_nonio.h:1869:62: note: saw 1 template<> , need 2 for specializing a member function template
messages<char>::do_get(catalog, int, int, const string&) const;
^

Compilation exited abnormally with code 1 at Sun Jan 18 21:15:55


Similar Content



Problems With "error: Invalid Conversion From `const Char*' To `char*' "

Hi, I need some help. I tried to install obs-ns. Itīs based on ns2, but when I ran "make", the problem below appears... please I wish anybody would help me.


This is the error:

Code:
OBS/ns-2/integrated_agent.h: In constructor `BurstManager::BurstManager()':
OBS/ns-2/integrated_agent.h:86: warning: `BurstManager::bt_' will be initialized after
OBS/ns-2/integrated_agent.h:84: warning:   `int BurstManager::currburstsize_'
OBS/ns-2/integrated_agent.cc:66: warning:   when initialized here
OBS/ns-2/integrated_agent.cc: In member function `int BurstManager::nhops(nsaddr_t, nsaddr_t)':
OBS/ns-2/integrated_agent.cc:81: error: invalid conversion from `const char*' to `char*'   <------- this is the error 
OBS/ns-2/integrated_agent.cc: In member function `virtual void IPKTAgent::recv(Packet*, Handler*)':
OBS/ns-2/integrated_agent.cc:180: warning: unused variable 'ipkth'
/root/OBS/ns-allinone-2.31/tclcl-1.19/tclcl.h:150: error: `void Tcl::error(const char*)' is private
OBS/ns-2/integrated_agent.cc:185: error: within this context
OBS/ns-2/integrated_agent.cc:155: warning: unused variable 'hdr'
OBS/ns-2/integrated_agent.cc: In member function `void IPKTAgent::deBurst(Packet*)':
OBS/ns-2/integrated_agent.cc:192: warning: unused variable 'hdrip'
OBS/ns-2/integrated_agent.cc:194: warning: unused variable 'ch'
make: *** [OBS/ns-2/integrated_agent.o] Error 1


And this is the code of the program...


Code:
int BurstManager::nhops(nsaddr_t src,nsaddr_t des) {
  Tcl& tcl = Tcl::instance();
  sprintf(tcl.buffer(),"$ns nhops %d %d",src,des);
  tcl.eval();
  char *ni = tcl.result();   <------this is the line 81 
  return atoi(ni);
}

Help To Disperse The Data Using Bitsplitter

I am totally new to Linux. I am working on Nubisave project in TU Dresden. I am stuck in running the C program. Its bitsplitter program. Can anybody help me out? should I post the program here? Will it be helpful for me? I knnow little basics of C language and the code is totally new for me.
I have used the code of bitsplitter and it is running but I am not understanding the output. This is code from Tu Dresden. Can anybody explain me how it is working?

#include "bitsplit.h"

#include <stdio.h>
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/errno.h>
#include <stdlib.h>
#include <string.h>

#define SPLITDEBUG 0

struct fillbyte_t {
char *bits;
int bitctr;
char bytes[1024];
int bytectr;
unsigned char numbits;
unsigned char shiftbits;
unsigned int pattern;
FILE *f;
char *buffer;
ssize_t bufferctr;
};
typedef struct fillbyte_t fillbyte;

struct bitsplit_t {
fillbyte *b;
int parts;
int redundant;
int totalbits;
};
typedef struct bitsplit_t bitsplit;

static void bitsplitfinish(bitsplit bs)
{
int j;

for(j = 0; j < (bs.parts + bs.redundant); j++)
{
if(bs.b[j].f)
fclose(bs.b[j].f);
free(bs.b[j].bits);
/*free(bs.b[j].buffer);*/ /* the caller clears this */
}
free(bs.b);
bs.b = NULL;
}

static bitsplit bitsplitprepare(const char *directory, int parts, int redundant, int bitwidth)
{
fillbyte *b;
bitsplit bs;
int ret;
char fname[1024];
int sumbits, totalbits;
int i, j;

bs.b = NULL;

if(directory)
{
ret = mkdir(directory, S_IRWXU);
if((ret != 0) && (errno != EEXIST)) return bs;
}

b = malloc((parts + redundant) * sizeof(fillbyte));
for(j = 0; j < (parts + redundant); j++)
{
b[j].bitctr = 0;
b[j].bytectr = 0;
b[j].buffer = NULL;
b[j].bufferctr = 0;
if(directory)
{
snprintf(fname, sizeof(fname), "%s/%i.stream", directory, j);
b[j].f = fopen(fname, "w");
}
else b[j].f = NULL;
}

sumbits = 0;
totalbits = (int)(((parts - 1) / bitwidth) + 1) * bitwidth;
#if SPLITDEBUG
printf("bitwidth: %i; totalbits: %i\n", bitwidth, totalbits);
#endif

if(redundant)
if(totalbits % parts != 0)
{
bitsplitfinish(bs);
return bs;
}

for(j = parts - 1; j >= 0; j--)
{
b[j].bits = (char*)malloc(totalbits * 8 * sizeof(char));

b[j].numbits = (int)((totalbits - sumbits) / (j + 1));
b[j].pattern = 0;
for(i = sumbits; i < sumbits + b[j].numbits; i++)
b[j].pattern |= (1 << i);
b[j].shiftbits = sumbits;
sumbits += b[j].numbits;
#if SPLITDEBUG
printf("bits: fragment %i=%i, pattern=%u\n", j, b[j].numbits, b[j].pattern);
#endif
}
for(j = parts; j < parts + redundant; j++)
{
b[j].bits = (char*)malloc(totalbits * 8 * sizeof(char));
}

bs.b = b;
bs.parts = parts;
bs.redundant = redundant;
bs.totalbits = totalbits;

return bs;
}

static int bitjoinwork(const char **inbuffers, ssize_t *insizes, bitsplit bs)
{
ssize_t i;
int j, k;
int target, revtarget;
int topk, topkcandidate;
int outbits;
int shifted;
int smallest;
int rels[16];
int inshift;

outbits = 8;
shifted = 0;

int xspecial = 0;

xspecial = 1;
if(bs.totalbits > 2 * bs.parts)
xspecial = 0;
if(xspecial)
for(j = 0; j < bs.parts; j++)
if(bs.b[j].numbits > 8) xspecial = 0;
if((bs.parts == 2) && (bs.totalbits == 11))
xspecial = 1;

if((!xspecial) && (bs.totalbits > 8))
outbits = 16;

topk = 0;
for(j = 0; j < bs.parts; j++)
{
topkcandidate = (int)((float)outbits / bs.b[j].numbits) - 1;
if(topkcandidate > topk)
topk = topkcandidate;
}
for(j = 0; j < bs.parts; j++)
{
rels[j] = (int)((topk + 1) / (outbits / bs.b[j].numbits));
// FIXME: mostly untested: =2, *=2 etc. yields 89 OKs
if((!xspecial) && (bs.totalbits > 8))
rels[j] = 2;
if(bs.b[j].numbits == 4)
{
if((bs.parts == 2) && (bs.totalbits == 9))
{
rels[j] = 1;
topk = 1;
}
}
#if SPLITDEBUG
printf("REL/%i=%i <<%i>>\n", j, rels[j], outbits);
#endif
}

smallest = (int)(insizes[0] / rels[0]);
if(((int)(float)insizes[0] * 2 / rels[0]) != smallest * 2)
smallest++;

inshift = (outbits - (topk + 1) * bs.b[0].numbits) % outbits;

int special = 0;
if((bs.parts == 2) && (bs.totalbits > 8))
special = 1;
int special2 = 0;
if((bs.parts == 2) && (bs.totalbits == 5))
special2 = 1;
if((bs.parts == 2) && (bs.totalbits == 7))
special2 = 1;
if((bs.parts == 3) && (bs.totalbits == 7))
special2 = 1;
int special3 = 0;
if((bs.parts == 5) && (bs.totalbits == 15))
special3 = 1;
if((bs.parts == 4) && (bs.totalbits == 12))
special3 = 1;
if((bs.parts == 3) && (bs.totalbits == 9))
special3 = 1;
int special4 = 0;
if((bs.parts == 3) && (bs.totalbits == 15))
special4 = 1;

target = 0;
for(i = 0; i < smallest; i++)
{
#if SPLITDEBUG
printf("- reverse source-pos:%li\n", i);
#endif
// FIXME: special; not for w=14||12, only for w=10!
if((special) && (bs.totalbits == 10) && (shifted >= 10))
{
shifted -= bs.totalbits;
if(shifted < 0)
shifted = 0;
}
#if SPLITDEBUG
printf(" remaining target:%i\n", target);
#endif

for(k = topk; k >= 0; k--)
{
for(j = bs.parts - 1; j >= 0; j--)
{
int packval = (int)(unsigned char)inbuffers[j][i * rels[j]];
// FIXME: read-ahead depends on the relative difference between numbits?
if(rels[j] == 2)
packval = (packval << 8) + (int)(unsigned char)inbuffers[j][i * rels[j] + 1];
// FIXME: special
if((!special) && (!special2) && (!special3) && (!special4))
packval >>= inshift;

int packshift = k * bs.b[j].numbits;
// FIXME: special; only for w=14||12, not for w=10!
if(special)
{
if(bs.b[j].numbits != 4)
packshift = k * 8 - bs.b[j].numbits;
if(bs.totalbits != 10)
packshift += 8;

// for 5+4 bits
if((packshift == 20) && (bs.b[j].numbits == 4))
packshift = 12;
else if((packshift == 16) && (bs.b[j].numbits == 4))
packshift = 8;
else if((packshift == 12) && (bs.b[j].numbits == 4))
packshift = 4;
else if((packshift == 8) && (bs.b[j].numbits == 4))
packshift = 0;
}
if(special2)
{
if((packshift == 9) && (bs.b[j].numbits == 3))
packshift = 13;
else if((packshift == 6) && (bs.b[j].numbits == 3))
packshift = 10;
else if((packshift == 3) && (bs.b[j].numbits == 3))
packshift = 5;
else if((packshift == 0) && (bs.b[j].numbits == 3))
packshift = 2;
}
if(special3)
{
if(packshift == 12)
packshift = 13;
else if(packshift == 9)
packshift = 10;
else if(packshift == 6)
packshift = 5;
else if(packshift == 3)
packshift = 2;
else if(packshift == 0)
continue;
}
if(special4)
{
if(packshift == 10)
packshift = 11;
else if(packshift == 5)
packshift = 3;
else if(packshift == 0)
continue;
}
#if SPLITDEBUG
printf("PACKSHIFT:%i (on val %i) [filtered:%i] [shifted:%i]\n", packshift, packval, (bs.b[j].pattern >> bs.b[j].shiftbits), shifted);
#endif
revtarget = (packval >> packshift) & (bs.b[j].pattern >> bs.b[j].shiftbits);
#if SPLITDEBUG
printf(" -> reverse target @%i[pos:%i]:%u\n", j, k, revtarget);
#endif
target += revtarget << shifted;
shifted += bs.b[j].numbits;
#if SPLITDEBUG
printf(" => target: %i (shifted:%i)\n", target, shifted);
#endif
if(shifted >= outbits)
{
while(shifted >= 8)
{
// FIXME: special; only for w>=10?
if((special) && (shifted == bs.totalbits))
break;
#if SPLITDEBUG
printf("@%li: %i [extra]\n", bs.b[0].bufferctr, target & 0xFF);
#endif
if(bs.b[0].bufferctr % 1024 == 0)
bs.b[0].buffer = (char*)realloc(bs.b[0].buffer, (bs.b[0].bufferctr + 1024) * sizeof(char));
bs.b[0].buffer[bs.b[0].bufferctr] = target & 0xFF;
shifted -= 8;
bs.b[0].bufferctr++;
target = (target - (target & 0xFF)) >> 8;
}
}
}
}
}

return 0;
}

static int bitsplitwork(const char *inbuffer, ssize_t insize, bitsplit bs)
{
ssize_t i;
int j, k, l;
int target, shifted, inshifted;
int precounted;

fillbyte *b;
int totalbits;
int parts;
int redundant;

int outbits;
int stuffingthreshold;

b = bs.b;
totalbits = bs.totalbits;
parts = bs.parts;
redundant = bs.redundant;

outbits = 8;
inshifted = 0;
stuffingthreshold = totalbits * 8;

for(i = 0; i < insize; i++)
{
if(inshifted > 8)
{
inshifted -= 8;
i += 1;
}
#if SPLITDEBUG
printf("- source-pos:%li\n", i);
#endif
for(j = 0; j < parts; j++)
{
//target = inbuffer[i] & b[j].pattern;
target = (*(int*)(inbuffer + i)) & (b[j].pattern << inshifted);
target = target >> (b[j].shiftbits + inshifted);
#if SPLITDEBUG
printf(" -> target @%i[pos:%i]:%u\n", j, b[j].bitctr, target);
#endif

b[j].bits[b[j].bitctr] = target;
b[j].bitctr++;
if(b[j].bitctr == stuffingthreshold)
{
target = 0;
shifted = outbits - b[j].numbits;
precounted = 0;
for(k = 0; k < b[j].bitctr; k++)
{
#if SPLITDEBUG
printf("@%i: (%i->%i) >> %i ; << %i\n", j, b[j].numbits, b[j].bits[k], b[j].shiftbits, shifted);
#endif
target |= (b[j].bits[k] << shifted);
shifted -= b[j].numbits;
if(shifted < 0)
{
b[j].bytes[b[j].bytectr] = target & 0xFF;
b[j].bytectr++;
shifted = outbits - b[j].numbits;
precounted++;
#if SPLITDEBUG
printf("@%i: [bytectr++]: %i {%i}\n", j, target & 0xFF, target);
#endif
target = target >> outbits;
}
}
//b[j].bytectr += (int)((b[j].numbits * totalbits * 8 - 1) / 8) + 1 - precounted;
b[j].bytectr += (int)((totalbits - 1) / 8);
#if SPLITDEBUG
printf("@%i: stuffed %i 'bits'/fragments; bytectr now %i\n", j, totalbits, b[j].bytectr);
#endif
b[j].bitctr = 0;
if(b[j].bytectr >= 1024 - stuffingthreshold)
{
if((j == 0) && (redundant))
{
#if SPLITDEBUG
printf(">> redundancy\n");
#endif
b[parts].bytectr = b[j].bytectr;
for(l = 0; l < b[parts].bytectr; l++)
{
b[parts].bytes[l] = 0;
for(k = 0; k < parts; k++)
b[parts].bytes[l] ^= b[k].bytes[l];
}
if(b[parts].f)
fwrite(b[parts].bytes, 1, b[parts].bytectr, b[parts].f);
else
{
b[parts].buffer = (char*)realloc(b[parts].buffer, (b[parts].bufferctr + b[parts].bytectr) * sizeof(char));
memcpy(b[parts].buffer + b[parts].bufferctr, b[parts].bytes, b[parts].bytectr);
b[parts].bufferctr += b[parts].bytectr;
}
}
if(b[j].f)
fwrite(b[j].bytes, 1, b[j].bytectr, b[j].f);
else
{
b[j].buffer = (char*)realloc(b[j].buffer, (b[j].bufferctr + b[j].bytectr) * sizeof(char));
memcpy(b[j].buffer + b[j].bufferctr, b[j].bytes, b[j].bytectr);
b[j].bufferctr += b[j].bytectr;
}
b[j].bytectr = 0;
#if SPLITDEBUG
printf("@%i: reset bytectr\n", j);
#endif
}
}
}

i += (int)((totalbits - 1) / 8);
if((totalbits % 8) != 0)
{
inshifted += totalbits % 8;
if(inshifted % 8 == 0)
{
i += (inshifted - 8) / 8;
inshifted = 0;
}
else
i--;
}
}

for(j = 0; j < parts; j++)
{
if(b[j].bitctr > 0)
{
target = 0;
shifted = outbits - b[j].numbits;
precounted = 0;
for(k = 0; k < b[j].bitctr; k++)
{
#if SPLITDEBUG
printf("@%i: (%i=>%u) >> %i ; << %i\n", j, b[j].numbits, b[j].bits[k], b[j].shiftbits, shifted);
#endif
target |= (b[j].bits[k] << shifted);
shifted -= b[j].numbits;
if(shifted < 0)
{
b[j].bytes[b[j].bytectr] = target & 0xFF;
b[j].bytectr++;
shifted = outbits - b[j].numbits;
precounted++;
#if SPLITDEBUG
printf("@%i: [final-bytectr++]: %i {%i}\n", j, target & 0xFF, target);
#endif
target = target >> 8;
}
}
if(shifted != outbits - b[j].numbits)
{
#if SPLITDEBUG
printf("@%i: final-partialbyte: %i\n", j, target & 0xFF);
#endif
b[j].bytes[b[j].bytectr] = target & 0xFF;
b[j].bytectr++;
precounted++;
}
//b[j].bytectr += (int)((b[j].numbits * b[j].bitctr - 1) / totalbits) + 1 - precounted;
// FIXME: this may need a more general treatment
if(totalbits != 16)
b[j].bytectr += (int)((totalbits - 1) / 8);
#if SPLITDEBUG
printf("@%i: final-stuffed %i 'bits'/fragments; bytectr now %i\n", j, b[j].bitctr, b[j].bytectr);
#endif
b[j].bitctr = 0;
}
if(b[j].bytectr > 0)
{
if((j == 0) && (redundant))
{
#if SPLITDEBUG
printf(">> final-redundancy\n");
#endif
b[parts].bytectr = b[j].bytectr;
for(l = 0; l < b[parts].bytectr; l++)
{
b[parts].bytes[l] = 0;
for(k = 0; k < parts; k++)
b[parts].bytes[l] ^= b[k].bytes[l];
}
if(b[parts].f)
fwrite(b[parts].bytes, 1, b[parts].bytectr, b[parts].f);
else
{
b[parts].buffer = (char*)realloc(b[parts].buffer, (b[parts].bufferctr + b[parts].bytectr) * sizeof(char));
memcpy(b[parts].buffer + b[parts].bufferctr, b[parts].bytes, b[parts].bytectr);
b[parts].bufferctr += b[parts].bytectr;
}
}
if(b[j].f)
fwrite(b[j].bytes, 1, b[j].bytectr, b[j].f);
else
{
b[j].buffer = (char*)realloc(b[j].buffer, (b[j].bufferctr + b[j].bytectr) * sizeof(char));
memcpy(b[j].buffer + b[j].bufferctr, b[j].bytes, b[j].bytectr);
b[j].bufferctr += b[j].bytectr;
}
}
}

return 0;
}

int bitsplitbuffer(const char *inbuffer, ssize_t insize, char ***outbuffers, ssize_t **outsizes, int parts, int redundant, int bitwidth)
{
int ret;
int j;
bitsplit bs;

if((!inbuffer) || (parts <= 0)) return -1;
if(bitwidth < 1) return -1;

bs = bitsplitprepare(NULL, parts, redundant, bitwidth);
if(!bs.b) return -1;

*outbuffers = (char**)malloc((parts + redundant) * sizeof(char*));
*outsizes = (ssize_t*)malloc((parts + redundant) * sizeof(ssize_t));
for(j = 0; j < (parts + redundant); j++)
{
(*outbuffers)[j] = NULL;
(*outsizes)[j] = 0;
}

ret = bitsplitwork(inbuffer, insize, bs);

for(j = 0; j < (parts + redundant); j++)
{
(*outbuffers)[j] = bs.b[j].buffer;
(*outsizes)[j] = bs.b[j].bufferctr;
}

bitsplitfinish(bs);
return ret;
}

int bitjoinbuffer(const char **inbuffers, ssize_t *insizes, char **outbuffer, ssize_t *outsize, int parts, int bitwidth)
{
int ret;
bitsplit bs;

if((!inbuffers) || (parts <= 0)) return -1;

bs = bitsplitprepare(NULL, parts, 0, bitwidth);
if(!bs.b) return -1;

ret = bitjoinwork(inbuffers, insizes, bs);

*outbuffer = bs.b[0].buffer;
*outsize = bs.b[0].bufferctr;

bitsplitfinish(bs);
return ret;
}

int bitsplitfile(const char *filename, const char *directory, int parts, int redundant, int bitwidth)
{
FILE *f;
char buf[1024];
ssize_t size;
int ret;
bitsplit bs;

if((!filename) || (parts <= 0)) return -1;

f = fopen(filename, "r");
if(!f) return -1;

bs = bitsplitprepare(directory, parts, redundant, bitwidth);
if(!bs.b) return -1;

while(!feof(f))
{
size = fread(buf, 1, sizeof(buf), f);
#if SPLITDEBUG
printf("read %li bytes\n", size);
#endif

ret = bitsplitwork(buf, size, bs);
if(ret != 0)
{
fclose(f);
bitsplitfinish(bs);
return ret;
}
}

fclose(f);
bitsplitfinish(bs);
return 0;
}

int bitjoinfile(const char *filename, const char *directory, int parts, int bitwidth)
{
FILE *f, **dfs;
char **dbufs;
ssize_t *dsizes;
int ret;
//bitsplit bs;
int j;
char fname[1024];

if((!filename) || (parts <= 0)) return -1;

f = fopen(filename, "w");
if(!f) return -1;

dfs = (FILE**)malloc(parts * sizeof(FILE*));
dbufs = (char**)malloc(parts * sizeof(char**));
dsizes = (ssize_t*)malloc(parts * sizeof(ssize_t));

for(j = 0; j < parts; j++)
{
snprintf(fname, sizeof(fname), "%s/%i.stream", directory, j);
dfs[j] = fopen(fname, "r");
if(!dfs[j]) return -1;

dbufs[j] = (char*)malloc(1024 * sizeof(char));
}

//bs = bitsplitprepare(directory, parts, redundant, bitwidth);
//if(!bs.b) return -1;

while(!feof(dfs[0]))
{
for(j = 0; j < parts; j++)
{
dsizes[j] = fread(dbufs[j], 1, sizeof(dbufs[j]), dfs[j]);
#if SPLITDEBUG
printf("read %li bytes\n", dsizes[j]);
#endif
}

ret = -1;
//ret = bitsplitwork(buf, size, bs);
if(ret != 0)
{
for(j = 0; j < parts; j++)
fclose(dfs[j]);
fclose(f);
//bitsplitfinish(bs);
return ret;
}
}

for(j = 0; j < parts; j++)
fclose(dfs[j]);
fclose(f);
//bitsplitfinish(bs);
return 0;
}

please respond as soon as possible.

Age Calculator, Pass By Reference Problem.

Hi, fellow programmers.
I am programming about an age calculator.
It's simple:
1, get the input date 'today', check if its valid
2, get the input date 'birthday', check if it's valid and before 'today'
3, calculate the difference and output.
This is a assignment due tomorrow and I have written the most of it, just needs some debugging, mostly about pass by reference. I declared date1&date2 at main and I have no idea how to call the value of them if I want to calculate them at another function. I guess I should probably declare them at struct Date, but I am not sure.
I would really appreciate it if you guys could tell me what to do.
Code:
/************************************************************
 *
 * Project 4: How Old Are You Really?
 *
 * Author: xx
 * Date: 6 May 2015
 *
 * This is a program designed to calculates the difference 
 * between two dates, which will be expressed in terms of
 * years, months and days.
 *
 ***********************************************************/

#include <bjarne/std_lib_facilities.h>

struct Date {
    int month;
    int day;
    int year;
// Member functions
Date get_date();
Date get_birth_date();
bool is_valid_date(int year, int month, int day);
bool is_before(Date& date1, Date& date2);
Date calculate_age(Date& date1,Date& date2);
};

// Declaration
Date get_date();
Date get_birth_date();
bool is_valid_date(int year, int month, int day);
bool is_before(Date& date1, Date& date2);
Date calculate_age(Date& date1,Date& date2);

int main()
{
    Date date1 = get_date();
    Date date2 = get_birth_date();
    Date get_date();
    // Check if the date is correct
    if (! is_valid_date(year, month, day))
    error("Date is not valid.");
    // Run how old or not?
    char go_on;
    cout << "Would you like to see how old you are (y/n)?\n";
    cin >> go_on;
    if (go_on=='n'){
    cout << "You are so chicken!";
    return 0;}
    else if (go_on!='y')
    error("Please enter y for yes or n for no.");
    Date get_birth_date();
    // Is birthday valid as well?
    if (! is_valid_date(int year, int month, int day))
    error("Date is not valid.");
    // Is the birthday before 'today'?
    if (!(is_before(Date& date1, Date& date2)))
    error("Your birthday should not be later than today, terminator.");
    // Calculate and give the answer.
    Date calculate_age();
}

Date get_date()
{
    Date date1;
    cout << "Welcome to the age calculator!\n";
    cout << "Please enter today's date (mm/dd/yyyy): ";
    int m;
    int d;
    int y;
    // To ignore the '/' during reading
    char slash;
    cin >> m;
    date1.month = m;
    cin >> slash;
    cin >> d;
    date1.day = d;
    cin >> slash;
    cin >> y;
    date1.year = y;
    cout << "Date entered was "<< date1.month << "/" << date1.day << "/" << date1.year <<"\n";
}

Date get_birth_date()
{
    Date date2;
    cout << "Please enter your birth date (mm/dd/yyyy): "; 
    int m;
    int d;
    int y;
    // To ignore the '/' during reading
    char slash;
    cin >> m;
    date2.month = m;
    cin >> slash;
    cin >> d;
    date2.day = d;
    cin >> slash;
    cin >> y;
    date2.year = y;
    cout << "Your birthday is "<< date2.month << "/" << date2.day << "/" << date2.year <<"\n";
}

// Is date valid?
bool is_vaild_date(int year, int month, int day)
{
    if (day<0)
    return false;
    if (month<1 || month>12)
    return false;
    // Check if the date exists or not considering there are have
    // different days when month varies
    int days_in_month=31;
    switch (month){
    case 2:
    days_in_month=28;
    break;
    case 4: case 6: case 9: case 11:
    days_in_month=30;
    break;
    }
    if (days_in_month<day)
    return false;
    return true;
}

//Date check - is birthday before 'today'?
bool is_before(Date& date1, Date& date2)
{
    if (Date& date1.year<Date& date2.year)
    return false;
    else if (Date& date1.month<Date& date2.month)
    return false;
    else if (Date& date1.day< Date& date2.day)
    return false;
    return true;
}

// Calculation
Date calculate_age(Date& date1,Date& date2)
{
    Date date3;
    date3.day = date1.day - date2.day;
    date3.month = date1.month - date2.month;
    date3.year = date1.year - date2.month;
    if (date3.day<0){
        date3.day = 30 + date3.day;
        date3.month = date3.month - 1;
    }
    if (date3.month<0){
        date3.month = 12 + date3.day;
        date3.year = date3.year - 1;
    }
    cout <<"You are " << date3.year <<" years, "<< date3.month <<" months, and " << date3.day <<" days old.\n";
}

Regarding Cross Compilation Of Ntp

hi all,
I am new to cross compilation .I am trying to cross compile ntp for arm based zync soc board. so i have downloaded ntp source code version ntp-4.2.8-p2

i gave options for confiure file like this ./configure --host=arm-xilinix-linux-gnueabi --build=x86_64-pc-linux-gnu --prefix=/home/sntp CC=arm-xilinx-linux-gnueabi-gcc -with-yeilding-select=yes
configuration is succesful but when i am going for make it is throwing an error like this

cd ./html && \
../scripts/build/checkHtmlFileDates
cd . && \
./scripts/build/checkChangeLog
make all-recursive
make[1]: Entering directory `/home/SNTP/ntp-4.2.8p2'
Making all in sntp
make[2]: Entering directory `/home/SNTP/ntp-4.2.8p2/sntp'
[ ! -r ./../COPYRIGHT ] \
|| [ check-COPYRIGHT-submake -nt ./../COPYRIGHT ] \
|| make check-COPYRIGHT-submake
cd ../libntp && make libntp.a
make[3]: Entering directory `/home/sumanth/SNTP/ntp-4.2.8p2/libntp'
CC systime.o
In file included from ../include/ntp.h:14:0,
from systime.c:9:
../include/ntp_crypto.h:27:25: fatal error: openssl/evp.h: No such file or directory
#include "openssl/evp.h"
^
compilation terminated.
make[3]: *** [systime.o] Error 1
make[3]: Leaving directory `/home/sumanth/SNTP/ntp-4.2.8p2/libntp'
make[2]: *** [../libntp/libntp.a] Error 2
make[2]: Leaving directory `/home/sumanth/SNTP/ntp-4.2.8p2/sntp'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/sumanth/SNTP/ntp-4.2.8p2'
make: *** [all] Error 2

suggest me how to fix this?

Regards
sumanth

Problem With (instalation Of?) Mysql.h On C

Hi, I've just recently installed MySQL connector/c from source code on my Slackware 14.1 x64

I read the official instructions of the connector but I felt a bit disorientated when I read:
Code:
1 -Change location to the top-level directory of the source distribution.

I interpreted that I have to go to the "highest" directory Code:
/

So I wrote: Code:
 
        #                            cd /

root@- /#                            tar xzvf /home/normal/Downloads/mysql-connector-c-6.1.6-src.tar.gz 

root@- /#                            cd /mysql-connector-c-6.1.6-src/

root@- /mysql-connector-c-6.1.6-src# cmake -G "Unix Makefiles"

root@- /mysql-connector-c-6.1.6-src# make 

root@- /mysql-connector-c-6.1.6-src# make install

Then I did:
Code:
ln -s /usr/local/mysql-5.6.25/include /usr/include

But when I try to compile a program in c with #include <mysql.h> i get this error:
Code:
# gcc ctemp.c 
In file included from ctemp.c:2:0:
/usr/include/mysql.h:57:27: fatal error: mysql_version.h: No such file or directory
 #include "mysql_version.h"
                           ^

What can I do? Thanks a lot and sorry for poor english

PD: If you need the official instructions I paste here the link: https://dev.mysql.com/doc/connector-...on-source.html

Which Perl Module To Include To Use String Length Function?

HI all,
I'm writing a perl script to automate VM UUID transformation into a format used by our ServiceNow CMDB/discovery.

Anyone know which perl module to include to use the string length function?

Alternately, how would I determine which perl modules exist that are available to include, vs. which functions each module contains?

thanks in advance,
Tracy Wiseman, software engineer, Silicon Valley

GCC Installation On RedHat 6.0

Hi

I am trying to install gcc on RedHat 6.0. I have installed
binutils 2.21
gmp 4.3.2
mpc 0.8.2
mpfr 3.0.0
ppl 0.10

but while making cloog-ppl 0.15 got an error shown below

what would be the reason?



gcc -DHAVE_CONFIG_H -I. -I. -I./include/cloog -I./include -I./include -I/usr/local/lib/include -Wall -fomit-frame-pointer -g -O2 -MT options.lo -MD -MP -MF .deps/options.Tpo -c source/options.c -fPIC -DPIC -o .libs/options.o
gcc -DHAVE_CONFIG_H -I. -I. -I./include/cloog -I./include -I./include -I/usr/local/lib/include -Wall -fomit-frame-pointer -g -O2 -MT options.lo -MD -MP -MF .deps/options.Tpo -c source/options.c -o options.o >/dev/null 2>&1
cd . && /bin/sh /opt/tools/cloog-ppl/autoconf/missing --run autoheader
autoheader: warning: missing template: HAS_SYS_RESOURCE_H
autoheader: Use AC_DEFINE([HAS_SYS_RESOURCE_H], [], [Description])
make[1]: *** [include/cloog/cloog-config.h.in] Error 1
make[1]: Leaving directory `/opt/tools/cloog-ppl'
make: *** [all-recursive] Error 1

Lvalue Required As Left Operand Of Assignment

//I get error when I write this code
#include<iostream>
using namespace std;
float v[]={10,15,20,25,30,35,40};
float me(int i);
int main()
{
cout<<"Values before change\n";
for(int i=0;i<5;i++)
{
cout<<"v["<<i<<"]="<<v[i]<<endl;
}
me(3)=99;
me(4)=100;
cout<<"\nValue after change"<<endl;
for(int i=0;i<5;i++)
{
cout<<"v["<<i<<"]="<<v[i]<<endl;
}
return 0;
}
float me(int l)
{
return v[l];
}
//And when I use return by reference the error is gone
#include<iostream>
using namespace std;
float v[]={10,15,20,25,30,35,40};
float& me(int i);
int main()
{
cout<<"Values before change\n";
for(int i=0;i<5;i++)
{
cout<<"v["<<i<<"]="<<v[i]<<endl;
}
me(3)=99;
me(4)=100;
cout<<"\nValue after change"<<endl;
for(int i=0;i<5;i++)
{
cout<<"v["<<i<<"]="<<v[i]<<endl;
}
return 0;
}
float& me(int l)
{
return v[l];
}
//But I cannot Understand Why

How To Use Static Libraries? Please Help Lol

https://code.google.com/p/wavelet1d/...ar.gz&can=2&q=

The above link is where I downloaded *.cpp(s) and the libraries.

If you "untar" the package, in "examples" directory, there are some demonstration files. What I wanted to do was to make an executable file out of "wavedemo1.cpp".

I modified the code in "wavedemo1.cpp"; Code:
#include "wavelet2d.h"

to Code:
#include "wavelet2s.h"

, then placed the header file "wavelet2s.h" (from /wavelib/src/linuxstatic) and the modified "wavedemo1.cpp" into my working directory.

Inside the working directory, I ran the following command

Code:
gcc -L/home/mario/wavelet/wavelib/linuxstatic -lwavelet2s wavedemo1.cpp -o wavedemo1

Then I get the following error messages.

/usr/bin/ld: skipping incompatible /home/mario/wavelet/wavelib/linuxstatic/libwavelet2s.a when searching for -lwavelet2s
/usr/bin/ld: cannot find -lwavelet2s
collect2: error: ld returned 1 exit status

I'm not sure what went wrong with my approach. This is my first time trying to use libraries on linux and it's giving me really tough times.

I would appreciate your help, please let me know if you need more details to explain things.

Thanks.

Zrp Integration

Hiii.. i am going to integrate the zrp in ns2.35 and facing the error.... plz help me to remove this error....


trace/cmu-trace.o: In function `hdr_zrp::access(Packet const*)':
cmu-trace.cc.text._ZN7hdr_zrp6accessEPK6Packet[hdr_zrp::access(Packet const*)]+0x7): undefined reference to `hdr_zrp:ffset_'
collect2: ld returned 1 exit status
make: *** [ns] Error 1
Ns make failed!
See http://www.isi.edu/nsnam/ns/ns-problems.html for problems