It is necessary to remove words from the array in the interval that the user entered. For example, from 3 to 6 words.

That's what I have written, but I get the error "invalid operands to binary - (have 'int' and 'int (*) (const char *)')" where "for (i = 0; i <w - remove + 1; i ++) "

#include <stdio.h> #include <string.h> #include <stdlib.h> #include <time.h> #include <windows.h> #include <conio.h> #define b 13 #define w 8 int a,j,i,index,remoe; char e; char *virk[b] = {"zilonis", "suns", "alnis", "zakis", "begemots", "lapsa", "dzeguze", "skudra", "vilks", "zirafs", "varna", "kakis","stirna"}; char *uzd[w]; char *arr[w]; void izvade(char *x){ printf("%8s\t",x); } void dzesana(char random[w]) { printf("No kura varda nodzest: "); scanf("%s", &index); printf("Cik nodzest:"); scanf("%s", &remoe); for (i = 0; i < index-1; i++) random[w]= arr[i]; for (j = index + remove - 1; j<w,j++,i++;) { random[w] = arr[j]; } for (i = 0; i < w - remove+1; i++) printf("%s ", random[w]); } main(){ for (a=0;a<b;a++) izvade(*(virk+a)); cikls: printf("\n"); printf("Tiek izvadits masivs ar nejausiem vardiem!"); printf("\n\n"); printf("\n"); getch(); printf("\nVardi tiks nodzesti"); printf("\n\n"); dzesana(); izeja: printf("\n\n"); printf("Vai Jus velaties atkartot?"); printf("\n"); printf("Ja(j) vai Ne(n)!"); scanf("%s", &e); if (e=='j')goto cikls; else if (e=='n') exit(0); else goto izeja; getch(); } 
  • 2
    Show your attempts to solve the problem, i.e. code. - edem
  • @AidenKothen Show that you’ve already done, otherwise your question will be deleted. Edit the question. - Vladimir Glinskikh
  • 1) At a minimum, the error is here: random[w] = arr[i] , since declared char *arr[w] but char random[w] . 2) remoe and remove - typo? 3) Try for the name of the functions to use English, understand Lithuanian (?) Here a little. - andy.37
  • There are many type mismatch errors in the code. In addition to the already voiced, also in scanf . When reading an integer, the format of the string %s indicated, must be %d . There are other errors. It is difficult to find an error in the code, which is almost entirely an error. - αλεχολυτ

1 answer 1

If your words are elements of an array, then the simplest option is to re-create the array and write all non-deleted words there. If you have an array of type char, then it’s the same, just read the lengths of the words and write them on the basis of this