Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding creating the stack using aarays #3883

Closed
3 tasks done
swagger20 opened this issue Nov 26, 2023 · 1 comment
Closed
3 tasks done

Regarding creating the stack using aarays #3883

swagger20 opened this issue Nov 26, 2023 · 1 comment

Comments

@swagger20
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues, especially the pinned issues.

Exception report

Last 200 Keys:
 . \ s t a c k _ w i t h o u t _ u s i n g _ s t l Space } Enter   
 c d Space " c : \ U s e r s \ W i n \ O O P S Space C O N C E P T 
S \ c o m p l e x _ l i n k e d _ l i s t \ s t a c k \ " Space ; Space i f Space ( $ ? ) Space { Space g + + Space s t a c k _ w i t 
h o u t _ u s i n g _ s t l . c p p Space - o Space s t a c k _ w i t h o u t _ u s i n g _ s t l Space } Space ; Space i f Space ( $ 
? ) Space { Space . \ s t a c k _ w i t h o u t _ u s i n g _ s t l Space } Enter


Exception:
or equal to zero and less than the console's buffer size in that dimension.
Parameter name: top
Actual value was -1.
   at System.Console.SetCursorPosition(Int32 left, Int32 top)      
   at Microsoft.PowerShell.PSConsoleReadLine.ReallyRender(RenderData renderData, String defaultColor)
   at Microsoft.PowerShell.PSConsoleReadLine.ForceRender()
   at Microsoft.PowerShell.PSConsoleReadLine.Insert(Char c)        
   at Microsoft.PowerShell.PSConsoleReadLine.SelfInsert(Nullable`1 
key, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.ProcessOneKey(ConsoleKeyInfo key, Dictionary`2 dispatchTable, Boolean ignoreIfNoAction, Object arg)
   at Microsoft.PowerShell.PSConsoleReadLine.InputLoop()
   at Microsoft.PowerShell.PSConsoleReadLine.ReadLine(Runspace runspace, EngineIntrinsics engineIntrinsics)

Screenshot

![Capture](https://github.com/PowerShell/PSReadLine/assets/133804817/cd983561-cfb0-4111-a7ce-74244aa
Capture
8d4ba)

Environment data

PS Version: 5.1.19041.3031
PS HostName: ConsoleHost
PSReadLine Version: 2.0.0-beta2
PSReadLine EditMode: Windows
OS: 10.0.19041.1 (WinBuild.160101.0800)
BufferWidth: 174
BufferHeight: 24

Steps to reproduce

#include
using namespace std;
class Stack{
public:
int top;
int *arr;
int size;
Stack(int size){
arr=new int[size];
this->size=size;
top= -1;
}
//functions
void push(int data){
//2 scenarios: space available nd space not available i.e. if stack is already full or a empty space is there for insertion of an element
if(size-top> 1){
//if space is available then top index is increased and in the array at that index new element will be inserted
top++;
arr[top]= data;
}
else{
//if space is not available
cout<<"Stack overflow"<<endl;
}

}
void pop(){
if(top==-1){
//if stack is already empty, no element is there to remove
cout<<"Stack Underflow"<<endl;
}
else{
//This will eventually point to the previous element of the already old pointed top just top-- will now point to the previous element it will give the index of that previous element
top--;
}
}
int getTop(){
if(top==-1){
cout<<"There is no elemet in the stack"<<endl;
}
else{
return arr[top];
}
}
int getsize(){
//This will give the no. of valid elements present in the stack top to inde ko bta hi rha hh to usme +1 kr do it will give you the total element sof the stack bcoz top hi apko last element ka index deta hh
return top+1;
}
bool isempty(){
if(top==-1){
return 1;
}
else return 0;
}
};
int main(){
//stack creation we have to give the size of the array as in the constructor we have defined the paramter of size so size of array is passed of 10

Stack s(4);
//insertion
s.push(34);
s.push(21);
s.push(70);
s.push(90);
s.push(30);
while(s.isempty()!=1){
cout<<s.getTop()<<" ";
s.pop();
}
cout<<endl;
cout<<"Size of stack as all the elemnts are removed bcoz of popping them to get them printed:"<<s.getsize();
s.pop();

return 0;
}

Expected behavior

NA

Actual behavior

NA

@microsoft-github-policy-service microsoft-github-policy-service bot added the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Nov 26, 2023
Copy link

@swagger20, you were using a pretty old version of PSReadLine (2.0.0-beta2 or prior), and it's likely that the issue was fixed in a newer version.
Please upgrade to the 2.3.4 version of PSReadLine from PowerShell Gallery.
See the upgrading section for instructions. Please let us know if you run into the same issue with the latest version.

@microsoft-github-policy-service microsoft-github-policy-service bot removed the Needs-Triage 🔍 It's a new issue that core contributor team needs to triage. label Nov 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant