Advertisement Jump to content
  • Advertisement


  • Content Count

  • Joined

  • Last visited

Community Reputation

122 Neutral

About Bleakcabal

  • Rank

Recent Profile Visitors

The recent visitors block is disabled and is not being shown to other users.

  1. Hi, whenever I am working with C-style strings under Linux ( and I can remember once under Solaris ) I tend to have some problems I do not encounter while working under Windows with MS compiler. From time to time I get garbage characters at the end of my strings. Here is some code I posted in the general forums : void sub(char *desc, char *text) { char string[255]; char *temp; while (!feof(stdin)) { fgets(string, 255, stdin); if (!feof(stdin)) { temp = strstr(string, desc); if (temp == NULL) { printf("%s", string); } else { printf("%s%s", text, temp); } } } } I thought it was fine and people there seemed to agree but sometimes printf is printing some garbage characters at the end of it's output. This usually happens when temp == NULL while it wasn't NULL in the loop before.
  2. Bleakcabal

    C, strstr, strings question

    Quote:Original post by perfectly_dark I can't see anything wrong with the code. Your garbage characters are probably in the string recieved from fgets. Like Evil mentioned, they're probably non printing characters like newline and CR. Try manually filling string with some test data and see if that fixes it. I'm doing this under linux, every time I work with strings under Linux I tend to get some crap at the end of my strings every now and then. My guess is that some library or whatnot isn't implemented the same as under Windows.
  3. Bleakcabal

    C, strstr, strings question

    Shouldn't printf stop at the carriage return, end of line characters, thus, I should'nt be able to see them ?
  4. Here is a C fonction I have programmed and written here in a simplified manner : void sub(char *desc, char *text) { char string[255]; char *temp; while (!feof(stdin)) { fgets(string, 255, stdin); if (!feof(stdin)) { temp = strstr(string, desc); if (temp == NULL) { printf("%s", string); } else { printf("%s%s", text, temp); } } } } What I am getting is after a line that goes into the else clause ( meaning strstr(string, desc) wasn't null ) the following line there are some garbage characters which are printed, even if it only prints the string which should'nt be affected by strstr. I took strstr usage's ( returning it to a char * ) directly from an example on the net. What am I doing wrong here ?
  5. Yes maybe the awnser is just to learn as many languages as possible and carefully read their docs. So far I have coded in C/C++, Ada, Assembler, Java, Visual FoxPro, C#, Basic and Python.
  6. Hi, I am looking for some good resources on the web on programming languages. I searched on my own but did not find any really great sites that talk about language semantics, the vocabulary of programming languages, the different approaches at creating languages, discussion of pros and cons of different features. I am not looking to create my own language but I am asking out of personal interest. I know this seems more like the content of a college course than something you find online but has anyone found good information on these subjects ?
  7. Bleakcabal

    Instancing child class in base class

    Im not offended. As for my spelling english is not my primary language. For example I know that primary language is probably not the right way to say this, but I don't know how to say it better :( Instantiate is written Instancier in french ( I am a french canadian from Quebec ) so I mixed up the spelling.
  8. Bleakcabal

    Instancing child class in base class

    I used to be quite good at OO programming. Unfortuntly since I got a job programming I stopped programming at home and at work I program with old decrepit languages :) under the old ( yuck ) structured programming methods... I would rather be doing some .NET, Java or C++ but the job is really great apart from that. But now I am trying to get back at it but I realize I forgot A LOT. It's been over at least 2 years minimum since I have programmed or looked at OO code :( I think I should dust off the old books and re-immerse myself in OO. Thanks for your awnser, I understand it, it's always easier to understand something you just forgot. Man, writing this has made me feel old...
  9. I have a problem, I want to have a base class with child inherited classes. The parent class has a method named Instanciate(). BaseClass { Instanciate(); }; ChildClass { ContainedClass MyClass } In the child class I want to call instanciate to instanciate an object of ContainedClass MyClass. I would like the code to be generic and be in the Instanciate method of the parent class so I could have many child class with contained class of diferent types. How can I do this ? More importantly is it better just to put the code in the Child classes ?
  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!