locked
C++ Error RRS feed

  • Question

  • i am trying to build a traffic gererator. the debug picks up no errors but when i run it it won't work.  The error is at https://imgur.com/hLiaSvq. My code is

    #include "pch.h"
    #include <stdio.h>
    #include <iostream>
    #include <Windows.h>
    #include <string>

    using namespace std;

    char x = 0;
    int y = 0;
    int a = 0;
    char z = 0;

    int main()
    {
    printf("Enter Website to Bot\n");
    scanf("%c", x);
    printf("Number of Bots to Send to Link\n");
    scanf("%s", y);
    printf("Browser You Would Like to Open Website In\n");
    scanf("%c", z);

    while (x < a) {
    system("<z> x");
    x = x-1;
    }
    }


    Thursday, August 30, 2018 3:50 AM

All replies

  • Your code has several problems:

         The first scanf needs &x, not x, as the second argument.  Same issue with third scanf.

         The second scanf needs %d and &y, not %s and y, to read an int into y.

         Your while statement will evaluate to false since x will be positive.

         Your call to the system function will not cause <z> or x to be expanded and replaced with the one character values of z and x.  It will actually try to execute the command <z> and the argument to that command will be the letter x.

    Your design has problems also:

         How do you intend to fit the name of a website in a single char?

         How do you intend to fit the name of a browser in a single char?

         Why are you using global variables?

         Why are you including unused headers pch.h, iostream, and string?

         Why are you compiling as C++ when your entire function is in C?

    You need to acquire some basic programming skills before attempting a complicated project.  You will get much better support if post in one of the Visual C forums.

    And once you acquire the skills, you should pick a project other than trying to launch a denial of service attack against a website.  If you persist in this particular endeavor, you will probably get no help at all in any of these forums.

    Thursday, August 30, 2018 3:51 PM