CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com

Search:

Type: Posts; User: chibicitiberiu

Page 1 of 2 1 2

Search: Search took 0.01 seconds.

  1. Re: Problem with allocating memory dynamically

    And I have another strange problem with the debugger and CodeBlocks: I put a breakpoint, press F8 but it doesn't stop there, breakpoints don't have any effect. Neither does the 'Run to cursor'...
  2. Re: Problem with allocating memory dynamically

    I see the error now, thanks for help.





    This is not the final and complete version of the program. I cut some functions and parts so it wouldn't be too long.
  3. Problem with allocating memory dynamically

    I've just learned to allocate memory dynamically and I got in trouble with a program.
    Here is my program:



    #include <fstream>
    using namespace std;


    struct soldatti {
  4. Re: Calculating number of divisors of a number

    And wouldn't that do the same job? Instead of verifying every number it first verifies the numbers divisible by two and then the rest of them, it would take the same time.
  5. Re: Calculating number of divisors of a number

    Okay, now I tried to test the primes method, but since the limit is 2 billion it generated a file of about 3 megabytes before I forced stopped it after like 3 minutes (it was taking too long) and the...
  6. Finding out the last digit of n at the n-th power

    This is a really big problem, how do I find the last digit of n at the n-th power?

    I did some experiments and this is what I discovered:
    Last digit of 1^4=1
    Last digit of 2^4=6
    Last digit of...
  7. Re: Calculating number of divisors of a number

    I did that before sending the source to infoarena.ro, and it fails 3 tests out of 10 because it takes too long.
    I need one small improvement, that's all.


    And by the way, it needs to calculate...
  8. Re: Calculating number of divisors of a number

    Bad idea. I'm limited to 650k of RAM and .1 seconds.
    And the restrictions:
    * 1 ≤ a ≤ b ≤ 2000000000.
    * 0 ≤ b - a ≤ 20000.
    So yes, it would take hours to get all prime numbers smaller than...
  9. Re: Calculating number of divisors of a number

    That isn't a very good idea either. Reading from files also takes long time, and it's an online competition where I upload the source code and it automatically compiles it and gives the result, it's...
  10. Re: Calculating number of divisors of a number

    The program works, but it's just too slow.
    Is there any way I can make it faster?
  11. Calculating number of divisors of a number

    How to calculate the number of divisors of a number?

    The classic algorithm:


    for (int i=1;i<n;i++) //or anything similar
    if (n&#37;d==0) no++;

    is way too slow.
  12. Replies
    2
    Views
    481

    Re: Trouble with TicTacToe game

    Okay I found the issue, it was with the checkocasions(&x, &y) function, I accidentally reversed the x with the y axis at the second diagonal axis, now I reversed that and it works. Now let's see who...
  13. Replies
    2
    Views
    481

    Trouble with TicTacToe game

    I have recently built this game TicTacToe, but I get some bugs with the AI, maybe you can help me.

    Here is the source code:

    #include <iostream>
    #include <stdlib.h>

    using namespace std;
    ...
  14. Replies
    20
    Views
    1,933

    Re: String problems

    Thanks, but this doesn't work in my compiler, it says "Syntax error" at the lines where is declared "bool ...".

    Now I have a question... will console programs made in MS Visual Studio (2005) work...
  15. Replies
    20
    Views
    1,933

    Re: String problems

    I now see that I said the wrong thing :D. It doesn't need 'using namespace std;' at the beginning of the program or 'std::' to access functions. What it doesn't have is 'vector', 'string' and other...
  16. Replies
    20
    Views
    1,933

    Re: String problems

    Than how do I do that? I don't really know how to allocate memory, i know very few information about pointers.
    How do I know how much memory will this string need?
  17. Replies
    20
    Views
    1,933

    Re: String problems

    It did grow with 1 byte, but not any more since it first writes and then reads, so it dumps the extra byte .
  18. Replies
    20
    Views
    1,933

    Re: String problems

    I found this information in several programming books.
    Anyway, how do I make this thing work?
  19. Replies
    20
    Views
    1,933

    Re: String problems

    Declaring 'string' variables in BC3.1 is not supported. I can only use char arrays.
    And char* behaves (or at least should) like a string, and unlike arrays should have a big number of characters,...
  20. Replies
    20
    Views
    1,933

    Re: String problems

    Well, this is the copyfile function:

    //COPYFILE FUNCTION
    //=================
    // - Copies a file from the source location to the destination in binary mode

    int copyfile(char source[], char...
  21. Re: How can I sort the lines in a file?

    Yes, I'm stuck with it. I tried others, but the applications were not working under DOS, only under Windows.
  22. Replies
    20
    Views
    1,933

    String problems

    I'm using Borland C++ for DOS 3.1, and lately I have been having some weird problems with strings. For example, I have a function that copies a file binary

    int copyfile(char source[], char...
  23. Re: How can I sort the lines in a file?

    Nope, BC 3.1 does not support std:: functions, and "vector" does not exist.
  24. Re: How can I sort the lines in a file?

    How do I do that?
    Note that I'm using Borland C++ 3.0 (for DOS) and not MS Visual Studio.
  25. Replies
    2,690
    Views
    1,020,479

    Re: What Song Are You Listening To Now¿

    Hillsong - Where we belong
Results 1 to 25 of 26
Page 1 of 2 1 2





Click Here to Expand Forum to Full Width

Featured