Returning a value.

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Parul Bagadia
    New Member
    • Mar 2008
    • 188

    Returning a value.

    I m returning a value of pointer of a structure from one function to main; but whenever it comes in main it becomes NULL... i used another pointer in main and equated its value to returning pointer but its still becoming NULL. I also tried removing its initialization from main; but ivvain.
    So, what is to be donr to retain its value? Actually i want to use the same value in other function; which m calling from main.
  • Parul Bagadia
    New Member
    • Mar 2008
    • 188

    #2
    Here is the code for reference!

    Code:
    Full code removed per Posting Guidelines' request that only the relevant portion be posted
    Last edited by sicarie; Apr 9 '08, 07:32 PM. Reason: Posting Guidelines

    Comment

    • jackie79
      New Member
      • Feb 2008
      • 2

      #3
      Dear Parul...

      Please specify the from which function you are returning the pointer to main.

      Rgds
      Jack Aegan

      Comment

      • Parul Bagadia
        New Member
        • Mar 2008
        • 188

        #4
        From struct dl merge(struct dl *p)function.

        Comment

        • Ganon11
          Recognized Expert Specialist
          • Oct 2006
          • 3651

          #5
          You are not returning a pointer, you are returning the dl struct pointed to by p. I'll check your code to see how you're treating the return value, but this might be a point of confusion.

          Comment

          • Parul Bagadia
            New Member
            • Mar 2008
            • 188

            #6
            I have discarded that return statement..
            But now i have a diff. problem, here what i need to do is to print the merged list! If i use pointer z; it points only the last value....i know it travereses the list till end and goes till last value; but it was having links earlier in complete list.....
            So, even if i take another pointer to traverse the list; it may come till end and will print nothing!
            The two lists which m merging here are sorted..
            I tried with making z local as well global;didnt work!; even tried with passing the value of sec which holds second list; but if i have a value from first list which is smallest; second list wont print it.
            Although i assign links like that.
            Same the case with ref;which holds first list.......; if i pass ref in display function; it wont print the small values of second list.
            It's about Doubly Linked List.

            Comment

            • Parul Bagadia
              New Member
              • Mar 2008
              • 188

              #7
              Here is the code for reference!
              void merge merges the two sorted lists; and dismerge print the two sorted lists.
              Code:
              full code removed per posting guidelines - please review the section that asks for [b] the relevant section of code only[/b]
              Last edited by sicarie; Apr 10 '08, 01:56 PM. Reason: code removed

              Comment

              • Parul Bagadia
                New Member
                • Mar 2008
                • 188

                #8
                I need to know this a bit early.
                Thank you.

                Comment

                • hsn
                  New Member
                  • Sep 2007
                  • 237

                  #9
                  i've skimmed through the code but i couldn't see any problems with it. but in line 16 you don't need else break. it will happen by it self if not the statement then go forward.
                  i need to test your code to find the problem i don't oknow why bytes removed it you were asking for help try to post it again they may not remove it.
                  let us see the hole code.

                  see you and good luck

                  hsn

                  Comment

                  • Parul Bagadia
                    New Member
                    • Mar 2008
                    • 188

                    #10
                    Originally posted by hsn
                    i've skimmed through the code but i couldn't see any problems with it. but in line 16 you don't need else break. it will happen by it self if not the statement then go forward.
                    i need to test your code to find the problem i don't oknow why bytes removed it you were asking for help try to post it again they may not remove it.
                    let us see the hole code.

                    see you and good luck

                    hsn
                    Thanx but i have solved it by myself........ without anybody's help.
                    And i dont know why my code was removed.....
                    Who cares; i did it..

                    Comment

                    • hsn
                      New Member
                      • Sep 2007
                      • 237

                      #11
                      good for you m8

                      hope best of luck to you

                      regards

                      hsn

                      Comment

                      • SpecialKay
                        New Member
                        • Mar 2008
                        • 109

                        #12
                        Hey,
                        I read the rules and i though that it was Fine for someone to post full code if they are asking for help.
                        I thought the rule on the Full code posting was only for the experts, in not giving people the answer to eazy

                        Comment

                        Working...