Comparison of Integer and Pointer (that's supposed to be an Integer). Where did I go wrong?

Joined
Nov 19, 2022
Messages
2
Reaction score
0
Hi!
Basically I tried to create a program that is shifting the components of an array.
Now I get a warning for the i < textlaenge part.
I think the textlaenge (textlength) part became a pointer somehow but I thought I'd have defined it as an Integer.
Do you have any idea? It would help me a lot!
Thanks in advance!

#include <stdio.h>

int textlaenge(char text[]) {
int laenge = 0;
while (text[laenge] != '\0') //mit '\0' werden C-Strings abgeschlossen
++laenge;
return laenge;
}

void shiftString(char text[], int shift) {
for(int j = 0; j < shift; j++){
for(int i = 0; i < textlaenge; i++){
if(i < textlaenge - 1)
text = text[i+1];
else
text = text[0];
}
}
}

int main(void) {
char str[25] = "Das ist der Originaltext"; // Originaltext

printf("Original: %s\n", str);
shiftString(str, 5);
printf("Verschoben um %d stellen: %s\n", 5, str);
shiftString(str, 19);
printf("Nochmal um um %d stellen verschoben: %s\n", 19, str);
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,053
Messages
2,570,431
Members
47,075
Latest member
TysonV438

Latest Threads

Top