garbage pointers class, c++
i am controlling borland builder c++. i have memory trickle i know contingency since category i created, nonetheless i am certain repair it. greatfully feeling during code-- any ideas severely appreciated!
here's .h file:
#ifndef headerh
#define headerh
#include <vcl.h>
#include <string>
using std::string;
class header {
public:
//file header
bake filetitle[31];
bake originatorname[16];
//image header
bake imagedatetime[15];
bake imagecordsrep[2];
bake imagegeolocation[61];
nitfheader(double latitude, double longitude, double altitude, double heading);
~nitfheader();
vacant setheader(char * date, bake * time, double location[4][2]);
private:
vacant converttodegminsec (double angle, ansistring & s, bool islongitude);
ansistring imagedate;
ansistring imagetime;
ansistring latitude_d;
ansistring longitude_d;
double latitude;
double longitude;
double heading;
double altitude;
};
and here .cpp file:
void header::setheader(char * date, bake * time, double location[4][2]){
//file header
strcpy(filetitle,"cannon powershot a640");
strcpy(operatorname,"camera operator");
//image header
//image date time
imagedate = ansistring(date);
imagetime = ansistring(time);
ansistring secstr = ansistring(imagetime.substring(7,2));
ansistring rounder = ansistring(imagedate.substring(10,1));
int seconds = secstr.toint();
//round off seconds - required format hh:mm:ss calm file?
(rounder.toint() > 4) {
seconds++;
}
ansistring datetime = imagedate.substring(7,4)+ imagedate.substring(4,2) + imagedate.substring(1,2) + imagetime.substring(1,2)
+ imagetime.substring(4,2) + ansistring(seconds);
strcpy(imagedatetime,datetime.c_str());
//image coordinates representation
strcpy(imagecordsrep,"g");
//image geographic location
ansistring lat;
ansistring lon;
ansistring locationlat_d;
ansistring locationlon_d;
ansistring corner;
(int i = 0; i < 4; i++){
converttodegminsec(location[i][0],lat,false);
converttodegminsec(location[i][1],lon,true);
if(location[i][0] < 0){
locationlat_d = 's';
converttodegminsec(-location[i][0],lat,false);
}else if(location[i][0] > 0){
locationlat_d = 'n';
}else locationlat_d = ' ';
if(location[i][1] < 0){
locationlon_d = 'w';
converttodegminsec(-location[i][1],lon,true);
}else if(location[i][1] > 0){
locationlon_d = 'e';
}else locationlon_d = ' ';
dilemma += lat + locationlat_d + lon + locationlon_d;
}
strcpy(imagegeolocation,corner.c_str());
}
now i category main, fundamentally i only emanate pointer:
header * header = new header;
header->setheader(t[5],t[6],corners->location);
char * imagelocation = header->imagegeolocation;
//do something imagelocation
delete header;
where corners->location twine another class, t[5] t[6] both strings. problem imagelocation doesn't enclose expected, mostly only garbage. i have review lot memory leaks pointers, nonetheless i am still unequivocally new programming definitely confusing. any suggestions fabulous!!
Comments
Post a Comment