stack

Finishing all activities started before the activity

微笑、不失礼 提交于 2020-01-22 12:31:49
问题 I want to finish all the activities which are running in the application means want to remove all the parent activities from stack. I want to implement logout functionality locally in my application so what I was thinking, I will finish all the activities started before and will start login activity again.. 回答1: I should let you know this is not a recommended behavior in android since you should let itself to manage life circles of activities. However if you really need to do this, you can

Why are Stack<T> and Queue<T> implemented with an array?

喜欢而已 提交于 2020-01-19 00:42:06
问题 I'm reading C# 4.0 in a Nutshell by the Albahari brothers and I came across this: Stacks are implemented internally with an array that's resized as required , as with Queue and List. (pg 288, paragraph 4) I can't help but wonder why. LinkedList provides O(1) head and tail inserts and deletes (which should work well for a stack or queue). A resizable array has O(1) amortized insert (if I remember right), but O(n) worst case (I'm not sure about delete). And it probably uses more space than the

Weird MSC 8.0 error: “The value of ESP was not properly saved across a function call…”

只愿长相守 提交于 2020-01-18 21:32:52
问题 We recently attempted to break apart some of our Visual Studio projects into libraries, and everything seemed to compile and build fine in a test project with one of the library projects as a dependency. However, attempting to run the application gave us the following nasty run-time error message: Run-Time Check Failure #0 - The value of ESP was not properly saved across a function call. This is usually a result of calling a function pointer declared with a different calling convention. We

C# Recursion Depth - How Deep can you go

懵懂的女人 提交于 2020-01-18 15:48:51
问题 Is there any control how much you can Recursively call something? From a basic test program I get a recursion depth of just over 18k which depends on the stacksize.... is there a way to set up a chunk of memory (perhaps a thread) with a massive stack to increase recursion depth? 回答1: I've increased the stack size during some documents recognition. It was really needed. So you can increase stack size for thread using following code: var stackSize = 10000000; Thread thread = new Thread(new

C- Character Push and Pop operation [closed]

泪湿孤枕 提交于 2020-01-17 12:49:10
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 5 months ago . Stack create(int c) { Stack S=(Stack)malloc(sizeof(struct stack)); S->size=c; S->top=-1; S->array=(char *)malloc(sizeof(char)*c); return S; } Stack makeEmpty(void) { Stack *S1=create(100); S1[0]->top=-1; return S1; } char pop(Stack S) { return S->array[S->top--]; }; int main(void) { Stack *S1; S1=makeEmpty();

Find all paths from one node to another in an undirected graph [adjacency list]

六月ゝ 毕业季﹏ 提交于 2020-01-17 05:51:06
问题 So I have a graph in the form of an adjacency list, structured as in the code below. Given this form of a data structure, I was wondering how it would be possible to go about finding and printing all the possible paths from a given node to another node. I'm aware I might have to used stacks to perform a DFS or queues to perform BFS, which I know how to do, but am confused by how to find all the possible paths typedef struct graph { int n, maxn; Vertex** vertices; }Graph; typedef struct vertex

Evaluating mathematical expression from a string and inserting it on stack

你离开我真会死。 提交于 2020-01-17 04:03:17
问题 I'm trying to build an arbitrary precision calculator. I represent numbers in linked lists (one node is a single digit), and I want to store them in a stack. However, I can't seem to figure out how to break the mathematical expression received as a string apart while keeping the right mathematical operations order. For example, if the inserted expression is 6*8-2+8-8*9/4 , I'll represent numbers as linked lists and insert them into a stack, and insert the operators into a different stack, and

What is the order of local variables on the stack?

扶醉桌前 提交于 2020-01-17 02:22:07
问题 I'm currently trying to do some tests with the buffer overflow vulnerability. Here is the vulnerable code void win() { printf("code flow successfully changed\n"); } int main(int argc, char **argv) { volatile int (*fp)(); char buffer[64]; fp = 0; gets(buffer); if(fp) { printf("calling function pointer, jumping to 0x%08x\n", fp); fp(); } } The exploit is quite sample and very basic: all what I need here is to overflow the buffer and override the fp value to make it hold the address of win()

Bits in a memory address

六月ゝ 毕业季﹏ 提交于 2020-01-16 18:26:09
问题 While debugging on Windows XP 32-bit using the immunity debugger, I see the following on the stack: _Address_ -Value_ 00ff2254 ff090045 00ff2258 00000002 My understanding is that every address location contains 8 bits. Is this correct? 回答1: If I'm understanding your question correctly, the answer is yes, every individual memory location contains 8 bits. The debugger is showing you 4 bytes (32 bits) at a time, to make the display more compact (and because many data types take up 32 bits, so it

Does the C language specify a stack? [duplicate]

孤者浪人 提交于 2020-01-16 17:43:16
问题 This question already has answers here : Size of stack and heap memory [duplicate] (4 answers) What and where are the stack and heap? (25 answers) Does C need a stack and a heap in order to run? (3 answers) Closed last year . Does the C language definition require the existence of a stack? What about architectures that don't support stacks? Does that mean that such architectures can't implement the C language as it is defined? What about the heap? 回答1: No. The C11 standard does not contain