trying to read from a string file

hey i keep getting a compile error in the function convert_to_binary. im new to c++ but any help is appreciated.the error message is invalid conversion frm 'char' to 'const char*'
im trying to get the longitude and latitude into degrees. thanks!


#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <math.h>
#define NUMERIC "0123456789"
#define rho 6378.1
#define PI 3.141593
struct place {
char * name;
double lat;
double lon;
};
int main()

{

char * line;
char * s_lat, * s_lon, * next;
double convert_to_binary(char *);
double distance_between(struct place *,struct place *);
double azimuth(struct place *,struct place *);


struct place * city_A[20], * city_B[20];

int len, i;

int num_of_pairs = 0;

FILE * cities;

line = (char *) malloc(80);

cities = fopen("city_pairs.txt","r");

while( fgets(line,80,cities) != NULL) {
/* allocate space for a pair of places */
city_A[num_of_pairs] = (struct place *) malloc(sizeof(struct place));
city_B[num_of_pairs] = (struct place *) malloc(sizeof(struct place));
len = strlen( line );

line[len - 1] = 0; /* put a zero byte over newline */

/* first_lat points to the first numeric char in the string */
s_lat = strpbrk(line,NUMERIC);
/* allocate space for the 1st city name */
city_A[num_of_pairs]->name = (char *) calloc(s_lat - line,1);
/* copy the 1st city name into the array of places */
strncpy(city_A[num_of_pairs]->name,line,s_lat - line - 1);

/* pass the 1st city latitude string to our conversion function */
city_A[num_of_pairs]->lat = convert_to_binary(s_lat);
/* get a string pointer to the longitude */
next = strchr(s_lat,' '); /* finds next blank */
s_lon = strpbrk(next,NUMERIC); /* finds the next digit */
city_A[num_of_pairs]->lon = convert_to_binary(s_lon);
/* find next blank char */
next = strchr(s_lon,' ');
/* repeat everything for the second city of the pair */
s_lat = strpbrk(next,NUMERIC);
/* allocate space for the 2nd city name */
city_B[num_of_pairs]->name = (char *) calloc(s_lat - next,1);
/* copy the 2nd city name into the array of places */
strncpy(city_B[num_of_pairs]->name,next,s_lat - next - 1);
/* pass the 2nd city latitude string to our conversion function */
city_B[num_of_pairs]->lat = convert_to_binary(s_lat);
/* get a string pointer to the longitude */
next = strchr(s_lat,' '); /* finds next blank */
s_lon = strpbrk(next,NUMERIC); /* finds the next digit */
city_B[num_of_pairs]->lon = convert_to_binary(s_lon);


/* increment num_of_pairs for next city pair */
num_of_pairs++;
};
/* process each pair and output the distance and azimuth */
for(i=0; i < num_of_pairs; i++) {
printf("The distance between %s and %s is %d km\n",city_A[i]->name,
city_B[i]->name, distance_between(city_A[i],city_B[i]));
printf("The azimuth angle from %s to %s is %d degrees\n",city_A[i]->name,
city_B[i]->name, azimuth(city_A[i],city_B[i]));
}
system("PAUSE");

return 0;

}
/*Converts dd:mm:ss into degrees*/
double convert_to_binary(char * s) {

float angle;
char * next;
angle= atof(s);
next=strpbrk(s,':');/*this where i get the error*/

angle= angle+atof (next)/60;
next= strpbrk(next+1,':');
angle=angle+atof(next)/3600;
return angle;
Looking at this makes me want to put out my eyes. Next time use [code][/code] tags.
Also, provide the complete error message. A line number would have been very useful, rather than having to look for your comment.

strpbrk(s,':');
Single quotes (') define an integral constant ('A' is the same as putting 65). On the other hand, double quotes (") define pointers to static C strings.
So, basically, when you need to pass ASCII/Unicode constant characters ('char' or 'wchar_t'), use single quotes. If you need to pass C strings ('char *' or 'wchar_t *'), even if they're just one character long, use double quotes.
OMG ur a genius!!!!!
Wow Helios! A Genius even hehe
*Shrugs in puzzlement*
Topic archived. No new replies allowed.