Search Results

Search found 2 results on 1 pages for 'skazhy'.

Page 1/1 | 1 

  • Converting c++ string to int

    - by skazhy
    Hi! I have the following data in a c++ string John Doe 01.01.1970 I need to extract the date and time from it into int variables. I tried it like this: int last_space = text_string.find_last_of(' '); int day = int(text_string.substr(last_space + 1, 2)); But I got invalid cast from type ‘std::basic_string’ to type ‘int’. When I extract the "John Doe" part in another string variable, all works fine. What's wrong? I am trying to compile it with g++ -Wall -Werror.

    Read the article

  • sorting char* arrays

    - by skazhy
    Hi! I have a datastructure struct record { char cont[bufferSize]; record *next; }; When I add new records to this structure, I want them to be sorted alphabetically. I made this function, that adds record in the right place (by alphabet) in the linked list: record *start=NULL, *p, *x; void recAdd(char*temp) { p = new record; temp[strlen(temp)] = '\0'; for (int j=0;j<bufferSize;j++) p->cont[j] = temp[j]; if (start==NULL) start=p; else { x=start; int c=0; while (recComp(x->cont,p->cont) <= 0 && x->next != NULL) { x=x->next; c++; } if (c == 0) { p->next=start; start=p; } else { x=start; for (int i=0;i<c;i++) x=x->next; p->next=x->next; x->next=p; } } for (int j=0;j<bufferSize;j++) temp[j] = NULL; }; But somehow it doesn't sort things right. What is wrong with my function?

    Read the article

1