Salem_c's Profile User Rating: ****-

Reputation: 2030 Grandmaster
Group:
Mentors
Active Posts:
4,004 (1.85 per day)
Joined:
30-May 10
Profile Views:
44,910
Last Active:
User is offline Apr 25 2016 11:59 AM
Currently:
Offline

Previous Fields

Country:
Who Cares
OS Preference:
Who Cares
Favorite Browser:
Who Cares
Favorite Processor:
Who Cares
Favorite Gaming Platform:
Who Cares
Your Car:
Who Cares
Dream Kudos:
0
Icon   Salem_c Gloom and DOOM!

Posts I've Made

  1. In Topic: Append to end of file for shell in C not working.

    Posted 26 Nov 2015

    cross-posted here -> http://cboard.cprogr...le-shell-c.html
  2. In Topic: Segmentation Fault

    Posted 24 Nov 2015

    Well the usual thing to do is compile the program with debug symbols, then run the code in the debugger.

    When it does segfault, the debugger will catch the fault and point you at the line of code causing the fault.

    From there, you can print variables to decide whether it's an invalid pointer or out of range subscript.

    Knowing these things, you can start to think about a solution.
  3. In Topic: destroying a whole stack

    Posted 24 Nov 2015

    Why is your pop_stack() calling malloc at all?

    Unless you have some bizarre dummy first node, your pop_stack needs to be a pointer

    int pop_stack ( stack_t *s, int *data) {
      if ( !s || !*s ) return -1;
      stack_t *temp = *s;
      *data = (*s)->datum;  // copy out the value
      *s = (*s)->next;  // advance ToS to the next element
      free(temp);  // free the now no longer used element
      return 0;
    }
    
    


    FWIW, hiding pointers inside typedef's just makes code more confusing.
  4. In Topic: Reading file into an array 5 integers at a time

    Posted 23 Nov 2015

    Well the ; at the end of line 42 isn't helping.
  5. In Topic: Understanding fstream User and Pass Login

    Posted 22 Nov 2015

    So what do you think while(!userValid) is doing, if it isn't going to cause the whole file to be read?

My Information

Member Title:
void main'ers are DOOMED
Age:
Age Unknown
Birthday:
Birthday Unknown
Gender:
Programming Languages:
C, C++, Perl, awk, various assemblers

Contact Information

E-mail:
Private