User Profile

Collapse

Profile Sidebar

Collapse
Cucumber
Cucumber
Last Activity: Oct 27 '08, 06:01 AM
Joined: Sep 24 '07
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • why is this post sticky? just wondering
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to How to create a new object
    in C
    What you want to do is easily done in .NET or java, because these languages have something known as Reflection.

    C++ has no reflection but you can simulate it:

    Code:
    class Base
    {
    public: Base * ClassFactory( ) = 0;
    };
    class X : public Base
    {
    public: Base * ClassFactory( )
               {
                    return static_cast<Base*>( new X() );
    ...
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to C++ and serial/com port
    in C
    Use CreateFile()
    and use "\\.\\COM1: " as the file name

    I googled it :P...
    See more | Go to post

    Leave a comment:


  • I never liked atoi, is it standard?

    I always used sscanf().
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to tangential velocoity and impact angle
    in C
    I think the moderator comment was right, but I am a math freak and I cant help solving math problems.

    Now, I am just assuming you are trying to calculate the tangencial vector to a surface when a vector hits the surface on a given point, and you already have the Normal vector of the surface at that point.

    So do this:

    Normalize the normal vector, hehe that sounds funny, but you have to do that. That means...
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to tangential velocoity and impact angle
    in C
    You are trying to use the dot product formula but you are not calculating correctly the modulus of both vectors.

    This is what you should do.

    Calculate the dot product and store it in a double variable "x".
    Calculate the modulus of the Normal vector and store it in a double variable "y"
    Calculate the modulus of the Velocity vector and store it in a double variable "z"
    ...
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to Memory placeholders in classes/structs
    in C
    I think this would be compiler dependant.

    However I remember seeing some pointer aritmetic to calculate the begining and the end of an object when loaded in memory somewhere inside the MFC source code.
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to Problems with file input/output
    in C
    Correct, if using "w" you can only write, is using "r" you can only read. I dont know whether there is a way to open files in Read and Write mode using C standard file functions.

    Win32 file functions allow opening files in read AND write mode though.
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to Problems with file input/output
    in C
    After taking a fast look, should not you be opening the file in read mode rather than write mode?
    Code:
    FILE *asciivalue_file;
    asciivalue_file = fopen("asciivalue.txt","w");//<--- should be "r"
    Also, when reading the characters and saving them into the array of characters, you should add the end of string.
    Code:
    i=0;
    while (i != 7)
    {
         lc = fgetc(asciivalue_file);
    ...
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to Question about c++ and game programming
    in C
    You can do some old style MSDOS game using a bit of software interruptions ( 0x10 ), and accessing Video Memory at location 0xA0000.

    Or you can do a Win32 based game. You would need to know the basics of WIn32 programming, and some accelerated graphics programming technology such as OpenGL or DirectX.

    My advice is, just jump into programming and ask any question you might have in your way. i.e. dont try turning yourself...
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to How to read .ocx file in C++ (Not MFC)
    in C
    The import directive is a Microsoft compiler's propietary prepocessor directive. What this directive does is reading any COM related import library and generate a C++ header file (at pre-compilation time).

    Note: Import libraries may live inside DLL or OCX files.

    Inside this header file generated at precomiplation time, live the interface definitions of the COM objects included in the import library. Once having these...
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to Static member
    in C
    The static variable is declared as private, so its not available outside class A.
    Declare it as public if you want to class B to use it or make Class B a friend class of A´s.


    Also dont forget to declare the static variable somewhere in your source code.
    I.e.
    Code:
    bool classA::xyz = true;
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to How can i optimize the follow function?
    in C
    Well, you can save a call to

    memset(tmp_num, 0,10);

    using

    tmp_num[0]=0;
    and doing
    tmp_num[j++] = **str;
    tmp_num[j]=0;

    I dont know whether that would help.

    Anyway, try using some optimization flag in your compiler, like -O2 or -O3 and see if your program speed improves.
    See more | Go to post

    Leave a comment:


  • Correct.


    As a side note, you would need to take a look into getEmployee when doing that change....
    See more | Go to post

    Leave a comment:


  • You will need a C parser.
    People actually make money creating parsers because they are very hard to create.
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to Binary adress book-minor syntax -- mitola
    in C
    use fflush(stdin)

    Code:
    void vnos(struct oseba pod,FILE *fd)
    {
    	printf("Vnesi ime: ");			scanf("%s",pod.ime);
                    fflush(stdin);
    	printf("Vnesi priimek: ");		scanf("%s",pod.priimek);
                    fflush(stdin);
    	printf("Vnesi ucni uspeh: ");	scanf("%d",&pod.ucni_uspeh);
                    fflush(stdin);
    ...
    See more | Go to post

    Leave a comment:


  • I would like to help but seems like doing so properly would require to take a look to many of your classes. I am going to try to assume a few things to help you:


    Code:
    // This is a copy constructor, notice you pass an Employee object to
    // the constructor, the point is making an exact copy
    Employee :: Employee( const Employee &employee )
    {
            FirstName = employee.FirstName; // I assume
    ...
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to Binary adress book-minor syntax -- mitola
    in C
    Use
    Code:
    gets();
    or

    Code:
    scanf("%[^\n]s",s);
    See more | Go to post

    Leave a comment:


  • Code:
    myEmployeeList.push_back(Employee());
    Im assuming this is a list (although it could be a vector, doesnt matter).

    This code creates an object in the stack, at that moment the constructor is called.

    Stack objects die when the function they are created in finishes (strictly speaking they die when the scope whithin they were created in finishes), so you see the destructor being called as...
    See more | Go to post

    Leave a comment:


  • Cucumber
    replied to Read the whole hard disk
    in C
    Never get discouraged when you want to learn something.
    A couple of hints:

    You might want to take a look into how the FAT works.
    And I think there should be a couple of software interruptions to read hard disk sectors directly.
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...