Thread: Help Code Is Not Working

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    and the Hat of Guessing tabstop's Avatar
    Join Date
    Nov 2007
    Posts
    14,336
    Fix your base case in printReverse so that it prints the entire array, not "the entire array except for the first element". Oh, and change void main to int main while you're there.

    Also how did this even compile? Removing conio.h, changing iostream.h to iostream and adding using namespace std, changing void main to int main, I still get this:
    Code:
    $ g++ -Wall -Wextra -o temp temp.cpp
    temp.cpp: In function ‘void longestMonotoneSubsequence(int, int*)’:
    temp.cpp:36: warning: right-hand operand of comma has no effect
    temp.cpp: In function ‘int main()’:
    temp.cpp:48: error: cannot convert ‘int (*)[100]’ to ‘int*’ for argument ‘2’
     to ‘void longestMonotoneSubsequence(int, int*)’
    The first warning is for delete back, rank -- that's only a memory leak; the second is the &a in the function call, which as the compiler correctly notes, is not an array, but a pointer to an array.

    Once I fix those, and fix the base case of print as mentioned above, I get the correct result (at least for your test case).
    Last edited by tabstop; 11-10-2008 at 10:32 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Code not working?
    By Elysia in forum C++ Programming
    Replies: 12
    Last Post: 04-06-2009, 01:57 AM
  2. Replies: 3
    Last Post: 02-24-2009, 08:49 PM
  3. C code not working
    By D3ciph3r in forum C Programming
    Replies: 2
    Last Post: 05-27-2005, 04:13 PM
  4. Trying to eject D drive using code, but not working... :(
    By snowfrog in forum C++ Programming
    Replies: 3
    Last Post: 05-07-2005, 07:47 PM
  5. Linked List Working Code
    By Linette in forum C++ Programming
    Replies: 9
    Last Post: 01-24-2002, 12:00 PM