User Profile

Collapse

Profile Sidebar

Collapse
rstiltskin
rstiltskin
Last Activity: Mar 11 '17, 02:03 PM
Joined: Feb 6 '10
Location:
  •  
  • Time
  • Show
  • Source
Clear All
new posts

  • rstiltskin
    replied to error LNK1120 and LNK2001
    in C
    There's nothing wrong with your code (at least as much as you have posted).

    You're probably using MS Visual C++ and have configured your project incorrectly. Be sure you create the project as a console application, not a win32 project.
    See more | Go to post

    Leave a comment:


  • rstiltskin
    replied to error: expected `;' before iter ?
    in C
    It looks like you forgot to
    #include <list>
    See more | Go to post

    Leave a comment:


  • In the definition of a function that takes an argument, you have to provide a name (identifier) for the argument as well as its type. And if you want the function to modify the value of that argument, that's the variable it should be working on, and not a local variable (one declared inside the function). So your getInformation should look like this:

    Code:
       int getInformation(int input)
     
            {
                scanf("%d",
    ...
    See more | Go to post

    Leave a comment:


  • You can use infile.tellg() to find out the position of the beginning of each line -- use it as the last statement in the loop so you'll know the position before each call to getline. Then adjust that value by the position of your search string in the line.

    http://www.cplusplus.com/reference/i...istream/tellg/

    By the way, your code doesn't seem to allow for the possibility that the search string might overlap the...
    See more | Go to post

    Leave a comment:


  • You omitted the control expression for the "else if" just before that cout.

    Code:
    else if (saleAmount > 0.00 && saleAmount <= 250.00)
    (shippingCharge = 5.00 + saleAmount);
    else if  // <== error is here
    
    [error] cout << endl << endl;
    // output
    cout << name << ", your shipping charge is " << shippingCharge << endl;
    cout
    ...
    See more | Go to post

    Leave a comment:


  • rstiltskin
    replied to Code Blocks question
    in C
    If you don't have the compiler, you installed the wrong Code::Blocks release. This is the one you need:
    http://prdownload.berlios.de/codeblo...ingw-setup.exe

    (Either one of the links on that page will give you Code::Blocks PLUS the MinGW compiler....
    See more | Go to post

    Leave a comment:


  • In C/C++, what you described is a 3 by 2 array, not 2 by 3.

    Assuming you are writing the function (not trying to use a pre-existing library function), you can pass the address of the beginning of the subarray, the dimensions of the subarray, and the offset (i.e. the size of the second dimension/number of columns) of the original array. Your function can use that offset to navigate through the subarray.

    So the function...
    See more | Go to post

    Leave a comment:


  • rstiltskin
    replied to Is any constructor necessary in C++?
    in C
    ... meaning either you don't write any constructor (e.g. you use the compiler-supplied default constructor) OR you write your own default constructor.

    In that sense, "default constructor" simply means a constructor that takes no arguments. It may initialize data members or perform other functions....
    See more | Go to post

    Leave a comment:


  • rstiltskin
    replied to Is any constructor necessary in C++?
    in C
    Not necessarily. It depends on your application.

    If you don't write a constructor, the compiler supplies a default constructor which creates your object but doesn't do anything else.

    If you want the member variables to be initialized, or if you want anything else done when the new object is created, then you have to write a constructor (or several constructors, depending on your requirements).
    See more | Go to post

    Leave a comment:


  • rstiltskin
    replied to Illegal Use of pointer
    in C
    Lines 16-17 should be:

    Code:
      x1=(-b+sqrt(d))/(2*a);
      x2=(-b-sqrt(d))/(2*a);
    because d is the argument that you are supplying to the sqrt function.

    Also, in order to comply w ith the C language standard, the return value of your main function should be int, not void, i.e.:
    Code:
    int main ()
    See more | Go to post

    Leave a comment:


  • rstiltskin
    replied to matrix multiplication and addition
    in C
    When you post code please use code tags so it will be easier to read.

    You didn't actually ask a question, so here's a link that might help.
    Multiplying a matrix by a vector is illustrated nicely in http://www.facstaff.bucknell.edu/mas...ecMultiply.htm. If you follow that example it's just a matter of looping through the array and the vector to do some simple multiplication and addition.
    See more | Go to post

    Leave a comment:


  • rstiltskin
    replied to Passing arrays to a function
    in C
    Thanks. I have no argument with that. I was just bothered because you seemed to be suggesting that typedef'ing an array changes the way that the compiler treats it -- in effect creating a new type rather than simply a 'nickname'.

    But I have to say that this
    is priceless. ;)...
    See more | Go to post

    Leave a comment:


  • rstiltskin
    replied to Passing arrays to a function
    in C
    I hope you don't mind my jumping in, but I'm puzzled by Banfa and donbock's posts. Should arrays be lumped together with all compound types? In Ectara's example, v is just an array of 3 floats, not a structure. Isn't it true that whenever an arrayname is passed as a function argument it is implicitly converted to a pointer ( although NOT when passed to the sizeof or addressof operators)? Isn't that required by both C and C++ standards, and not...
    See more | Go to post

    Leave a comment:


  • 1. It's normal behavior. To a C++ compiler
    Arr<int> pn = new int[pn.size = 10];
    is equivalent to
    Arr<int> pn(new int[pn.size = 10]);
    In fact, you can even define an int variable with the value 5 this way
    int i(5);
    in C++ (but not in C).

    2. Since you are using an int* to assign to a Arr object, the compiler is using the constructor as an implicit conversion operator, so yes, it's...
    See more | Go to post

    Leave a comment:

No activity results to display
Show More
Working...