Need help! Following code isnt working fully Comparison of integer and pointer

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
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top