Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- char* funkcja(char* text)
- {
- int i = 65; // kod ASCII znaku 'A' ///nasz licznik
- while (*text) {
- cout << "Przed zmiana: " << *text << " (" << (long long)text << "), "; // wpisywanie po kolei kolejnych liter
- *text = (char)i++; // i rosnie wiec kolejne litery to A B C
- cout << "po zmianie: " << *text << " (" << text << "), adres: "
- << (long long)text << endl;
- text++; // przejscie na kolejna litere
- }
- cout << "Wartosc (adres) zwrocona do funkcji wywolujacej (main): "
- << text << endl;
- return text;
- }
- int main()
- {
- char tab[] = "PJC"; //napis poczatkowy
- cout << "---- Przed wywolaniem funkcji ---" << endl;
- cout << "Napis tab = " << tab << ", adres: " << (long long)tab << "\n" << endl;
- cout << "---- Wywolanie funkcji ---" << endl;
- char* s = funkcja(tab); //aktualizowanie tabeli
- cout << endl;
- cout << "---- Po powrocie do funkcji wywolujacej (main) ---" << endl;
- cout << "Napis s (wartosc zwrocona przez funkcje) = " << s << ", adres: " // wpisanie n czyli jest to D ale ono nie istnieje w tablicy wiec mamy puste miejsce i jego adres
- << (long long)s << endl;
- cout << "Napis tab = " << tab << ", adres: " << (long long) tab << endl; // wpisanie nowego tab czyli ABC , puste miejsce i adres
- cout << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement