samedi 25 mai 2019

Multiple syntax errors in "simple denial of service" program

I have been working on a VERY simple denial of service program in C. I am not concerned about making the DOS effective. this is more of an experiment.

Anyway, I coded this program and when I tried to compile it returned errors that make no sense to me. I was wondering if someone could tell me what went wrong with the syntax.

P.S I think there may be an issue with the "DOS" function data type. am I supposed to change it to "char" since the parameters are characters as well?

//In progress local Denial Of Service program
#include <stdio.h>
#include <stdlib.h>

//initializes variables
int main() {

int i, j;

char k[70000];
char l[1];

//defining Denial of Service algorithm
int DOS(i, j, k) {

//Algorithm ; print string either infinitely or enough data to take 
 up too much process

 for(i = i; i < j; i++) {
      printf("%s ", k);
      return 0;
 }
}


 printf("enter value for i, j, and k.\n");

 printf("int i: \n\n");
 i = scanf("%d");

 printf("int j: \n\n");
 j = scanf("%d");

 printf("char k[]: \n\n");
 k[] = scanf("%s");

 printf("start DoS function? [y/n]: ");
 l[] = scanf("%c");

 if(char l[0] != "y") {
      printf("no selected. exiting...\n\n");
      getchar();
      exit(0);
 } else {
      DOS(int i, int j, char k);
 }


 return 0;

}

I was hoping for it to produce a prompt to declare the variables I J and K. and after that it was supposed to ask for confirmation to start Denial of Service. if I enter 'y' it was supposed to start printing infinite numbers to the screen (if given the right inputs).

these are the errors

DOS.c: In function 'DOS':

DOS.c:15:5: warning: type of 'i' defaults to 'int' [-Wimplicit-int] int DOS(i, j, k) { ^~~

DOS.c:15:5: warning: type of 'j' defaults to 'int' [-Wimplicit-int]

DOS.c:15:5: warning: type of 'k' defaults to 'int' [-Wimplicit-int]

DOS.c: In function 'main':

DOS.c:35:8: error: expected expression before ']' token k[] = scanf("%s"); ^

DOS.c:38:8: error: expected expression before ']' token l[] = scanf("%c"); ^

DOS.c:40:9: error: expected expression before 'char' if(char l[0] != "y") { ^~~~

DOS.c:45:15: error: expected expression before 'int' DOS(int i, int j, char k); ^~~

Aucun commentaire:

Enregistrer un commentaire