help!!!

Hi guys,I'm new in forum.I have a problem.When i write anyone type of function in my IDE(Monodevelop,Ubuntu 16.04) and i call her by main the program run completely but in the terminal don't appear anything why?

Thank you guys!
Last edited on
Did you actually output anything, or does the terminal just close too quickly for you to see ( http://www.cplusplus.com/forum/beginner/1988/ ) ?
No the terminal remain open but it doesn't appear anything.It happen only I call another function by main
Hello gekakav,

In both examples the first line concerns me. It looks like something is not set up correctly. Yet in the second link the for loop appears to work.

In the first link line 13 is a proto type not a function call. Since the function returns a "char" the function needs to return something or the function return type needs to be "void".

Line 13 should look like: char result alphabet(); or just alphabet();.

Hope that helps,

Andy
Just to illustrate by code what Handy Andy explained you:
The following code compiles with a warning:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

char alphabet()
{
    char alpha;
    for(alpha='a'; alpha<='z'; alpha++) {
        std::cout << alpha;
    }
}

int main()
{
    alphabet();
    return 0;
}


The following code compiles without any warnings:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
#include <iostream>

void alphabet()
{
    char alpha;
    for(alpha='a'; alpha<='z'; alpha++) {
        std::cout << alpha;
    }
}

int main()
{
    alphabet();
    return 0;
}


What’s wrong in your code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>

char alphabet() // <-- You declare that this function will return a char...
{
    char alpha;
    for(alpha='a'; alpha<='z'; alpha++) {
        std::cout << alpha;
    }
} // <-- ...but it ends returning nothing.

int main()
{
    char alphabet(); // <-- this is not a function call: it's a function prototype
                     // A function call looks like:
                     // alphabet();
    return 0;
}


Note: you can also declare the variable ‘alpha’ inside the for-loop block:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
#include <iostream>

void alphabet()
{
    for(char alpha='a'; alpha<='z'; alpha++) {
        std::cout << alpha;
    }
}

int main()
{
    alphabet();
    return 0;
}


Note 2: if you really want an answer, you should consider copying ans pasting your code inside the post, from where other users can take it and test it. In general, if you don't help other people help you, other people think you aren't really searching for help.
thank you guys! I'm begginer yet.
Topic archived. No new replies allowed.