contains warning

What is bad on my code? Funkcion naVelke

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

void nacitaj(char* str){
    fflush(stdin);
    str = fgets(str, 30, stdin);

    if(strchr(str, '\n') != NULL) str[strlen(str) - 1] = '\0';
}

void odstranZnak ( char inputFileName[],int  znak){

       while ((inputFileName = strchr(inputFileName, znak)) != NULL){
            (inputFileName[strlen(inputFileName)] = '\0');
            memmove(inputFileName, inputFileName + 1, 1 + strlen(inputFileName + 1));
        }
}

void odstranZnaky(char str[100]){ //parsovanie
    char vypis[100];
    vypis[0] = '\0';
    char * retStr;
    retStr = strtok (str, ",.-");
    while (retStr != NULL)
    {
        strcat(vypis, retStr);
        retStr = strtok (NULL, ",.-");
        strcpy(str, vypis);
    }
}

void naVelkeZaMedzerov(char* str){
        char c;
        c = str[0];
        str[0] = toupper(c);
        for (unsigned int i = 1; i < strlen(str); i++){
            if (str[i - 1] == ' '){
                c = str[i];
                str[i] = toupper(c);
            }
    }
}

void naVelke(char* str){
        char c;
        for (unsigned int i = 0; i < strlen(str); i++){
                c = str[i];
                str[i] = toupper(c);
        }
}


void poSlovachNaRiadok(char * str){
    char pomRetVyp[strlen(str)];
    pomRetVyp[0] = '\0';
    while (strchr(str,' ') != NULL) {
        strncpy(pomRetVyp, str, (strchr(str,' ')) - str);
        pomRetVyp[(strchr(str,' ')) - str] = '\0';
        printf("\n%s",pomRetVyp);
        strcpy(str, strchr(str,' ') + 1);
        if (strchr(str,' ') == NULL) printf("\n%s",str);
    }

}

void removeSubstring(char *s, char *toremove)
{
    while ( s = strstr(s, toremove)){
        (s[strlen(s)] = '\0');
        memmove(s, s + strlen(toremove), 1 + strlen(s + strlen(toremove)));
    }
}

int zmenZnakzaZnak(char* str, char* result, char ZnakOld, char ZnakNew){
    int pocetZmien = 0;
    int len = strlen(str);
    strcpy(result, str);
    for (unsigned int i = 0; i < len; i++){
        if (result[i] == ZnakOld){
            result[i] = ZnakNew;
            pocetZmien++;
        }
    }
return pocetZmien;
}

char* vymazVsetkoPredPodretazcom(char* str, const char* substr){
    char* podr;
    podr = strstr(str, substr);
    if (podr == NULL) return str;
    else return (podr);
}

void vlozRetNaPoziciu(char *str, char *vloz, char* vysledok, int pozicia){
    char retStr[strlen(str) + strlen(vloz)];
    retStr[0] = '\0';
    strncpy(retStr, str, pozicia);
    retStr[pozicia] = '\0';
    strcat(retStr, vloz);
    strcat(retStr, (str + pozicia));
    strcpy(vysledok, retStr);
}

void vymazOdPoziciePocet(char *str, int pozicia, int pocet){
    char retStr[strlen(str)];
    strncpy(retStr, str, pozicia);
    retStr[pozicia] = '\0';
    if (strlen(str) > pozicia){
        strcat(retStr, str + pozicia + pocet);
    }
    strcpy(str,retStr);
}

void podciarkniHladanyZnak(char* str, char znak){
    char podciarkni[strlen(str)];
    for (unsigned int i = 0; i < strlen(str); i++){
        podciarkni[i] = ' ';
        podciarkni[strlen(str)] = '\0';
        if (str[i] == znak) podciarkni[i] = '*';
    }
    printf("%s", podciarkni);
    //while (strchr(str, znak) != NULL){
    //    podciarkni[4] = '*';
    //    str = strchr(str, znak) + 1;
    //}
}

void podlaAbecedy (char* str){
    int zoradene = 0;
    int pom;

    while(zoradene == 0){
            zoradene = 1;
            for(unsigned int i = 0; i < strlen(str) - 1 ; i++){
                    if(str[i] > str[i+1]){
                            pom = str[i];
                            str[i] = str[i+1];
                            str[i+1] = pom;
                            zoradene = 0;
                    }
            }
    }
}


int main()
{
    char str[30];
    char str2[30];
    char str3[60];

    nacitaj(str);
    //nacitaj(str2);

    podlaAbecedy(str);

    printf("%s", str);

    return 0;
}
closed account (oGwfSL3A)
Can you tell us the warning message and what line you think it might be on? That's kinda a lot to go through.
Topic archived. No new replies allowed.