User Profile

Collapse

Profile Sidebar

Collapse
archonmagnus
archonmagnus
Last Activity: May 11 '09, 05:18 PM
Joined: Jun 18 '07
Location: The Interweb
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • Are you getting a compilation error, or just unexpected program behaviour? At first glance, I see to the output of the "get" iostream method as an integer type. If you read a reference for get(), you'll see that the expected variable type should be "char".
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to picking out a number from an integer
    in C
    If you don't have to store the input as an integer, you could store it as a string or a character array. That may be easier in displaying a specific character index value.
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to small error
    in C
    I do see a few errors in your code. First, the "sqrt" function is defined in the "cmath" library. Otherwise you have no function declaration for the "sqrt" function and the compiler complains that it can't find the function to use. In otherwords, add the preprocessor directive:
    [code=cpp]
    #include <cmath>
    [/code]

    Second, check the line:
    [code=cpp]
    ...
    ...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to Need help with a c++ program quitting
    in C
    There are a few things wrong with your code. First, I suggest replacing the depreciated library file "iostream.h " with the more compatible (and useful) "iostream". In other words, first change your first line to read:
    [code=cpp]
    #include <iostream>
    [/code]

    Next, by declaring a variable such as you've done with
    [code=cpp]
    char MONSTER;
    [/code]
    you've created...
    See more | Go to post

    Leave a comment:


  • I'm not sure what you mean by your statement. When I compile your code (using GCC version 4.1.2), I get the following output:
    [code=text]
    0x804a068
    3
    12
    34
    45
    benim 134520936
    [/code]

    In your code you have the following:
    [code=cpp]
    // This prints: "0x804a068"
    cout << &temp2->data[0] << endl;
    temp->pointer[0] = (int)(&temp2->data[0]);...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to how to solve this 2 errors ?
    in C
    The whitespace in a C++ code is (mostly) irrelevant and (mostly) serves to make the code more readily parsed by humans rather than the compiler. For instance, GCC readily compiles the following (admittedly mangled) code:

    [code=cpp]
    #include <iostream>

    using namespace std;

    int main (int argc, char *argv[])
    {
    unsigned
    short
    xyzzy
    = 0;
    ...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to structures
    in C
    You can, but it has to be inside of a constructor. Try the following:

    [code=cpp]
    #include <iostream>

    using namespace std;

    struct XYZZY
    {
    double foo, bar;

    // Here's the constructor
    XYZZY()
    {
    foo = 2.718281828;
    bar = 1.618;
    }
    // Here's the destructor
    ~XYZZY(){};
    }...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to allineing the output
    in C
    Since you are working with C++, I'd suggest looking into the inclusion of:

    [code=cpp]
    #include <iomanip>
    [/code]

    perhaps you'd be interested in using the functions from that library to handle your output alignment/formatting. Specifically the methods 'setw', 'setfill', 'setprecision', etc.

    See the reference here.
    See more | Go to post

    Leave a comment:


  • Brilliant! Thanks a lot. That's exactly what I needed. There are often days where I wish I had gone into computer science so I would know these kind of things. Thanks again for the reference.
    See more | Go to post

    Leave a comment:


  • Looking for an algorithm/example for plotting functions to pixel arrays

    Hello all,

    I've been experimenting with developing an orbital analysis program. Being a visually oriented person, I'd like to translate my (x, y) coordinate pairs to an pixel image array so I can plot the satellite ground tracks on a bitmap, JPEG, PNG, etc. If I simply truncate the values to integers, I'll only have discrete (an most likely) overlapping points rather than line segments that join pixels.

    Basically,...
    See more | Go to post

  • archonmagnus
    replied to calculating n factorial
    in C
    For one thing, it looks like you have an excess in the number of braces you have. Specifically, in the segment:
    [code=cpp]
    else if(n<=50)
    {
    {for(int i=n; i>=1; i--)
    {
    factorial *= i;
    }

    cout << "n! == " << factorial << endl;
    }
    else
    {
    {lnFactorial = (n*log(n))...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to Help With Switch Statements!
    in C
    You need a switch variable. For example:

    [code=cpp]
    #include <iostream>

    using namespace std;

    int main (void)
    {
    short method;
    bool exiting = false;

    while (!exiting)
    {
    // Prompt the user for a method choice
    cout<<"Select:" <<endl
    <<" 1.) Method 1"<<endl...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to calling a paricular data from excel sheet
    in C
    True that could be done, but if the OP's spreadsheets are those typical of the thermodynamical analytics field, they tend to have formulae and macros and cross references and sharks with lasers on their heads. Trust me, I speak from experience. I spent a good portion of last year converting those types of spreadsheet/VB macro calculation files into "real" programs that were much easier to use....
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to Serial Number and Registration
    in C
    C++ nor C nor any other language (that I can think of this late at night) has a built-in command for performing a hardware inventory scan. You might want to look into the use of the 'system' command to attempt to parse hardware information from files stored at a "standard" or "known" location on the disk (such as /dev or C:/Windows), but that could lead to other problems. For one, depending on the access permissions of the user...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to calling a paricular data from excel sheet
    in C
    Ah, a fellow thermodynamist! Unfortunately, you wouldn't be able to extract data from an excel file directly without knowing the filetype specification. Excel files are "binary" and data cannot be read using C++ as you would do with a simple ASCII data file. You would have to read a bytestream and parse the data according to the specification to find the particular thermal property reference of interest.

    Here's a link...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to Using a variable as a power
    in C
    Just a quick thought...

    You may be getting overloading of the "pow" function. Look up the function declarations of pow() relative to the variable type of "FIRST" (in your case). In other words, you may have to cast "FIRST" to either a float or a double to match one of the overloads.

    For example:
    [code=cpp]
    FACTORIAL = (pow(2.71828183 , (double)(-FIRST))
    ...
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to C++: Computing Factorials
    in C
    In regards to Man4ish's comment: you could also read up on Stirling's Approximation for the computation of n! for n >> 1.
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to Newton Raphson method
    in C
    A good place to start would be Wikipedia - Newton's Method. I'd also recommend reading Wolfram's Mathworld entry on Newton's Method.

    The main obstruction with using it for user-input functions is that you must know both f(x) and f'(x) beforehand. If, in your case, the polynomial is spelled out for you, it should be rather easy to implement.

    Give us some code to glean through and we can provide a bit more help.
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to sendmail
    in PHP
    Try the "mail()" function in PHP.

    Here's the documentation.
    See more | Go to post

    Leave a comment:


  • archonmagnus
    replied to C++: Computing Factorials
    in C
    Ganon's right. You can do one of two things to increase your maximum (but remember that the maximum is finite), try using an "unsigned int" or try using a double-precision variable and see your results. Remember that factorials get really big, really quickly.

    I'm kind-of a numerical methods junkie and, unfortunately, you can only stick so much into a four-byte word/int. ;)
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...