ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1002. Phone Numbers

Compilation error, C++
Posted by Thrall 5 Apr 2008 14:21
I have:

#include <iostream>
using namespace std;
(...)
int main()
{
    string x;
    int n;
    (...)
    cin >> x >> n;
    string good[x.size()+1];
    string tab[n], tab2[n];
    (...)
}

Dev C++ doesn't see any mistakes, but I have 5 compilation errors in these lanes:
0d51f7eb-98bd-4754-8632-86fafd7d0b29(43): error: expression must have a constant value
                 string good[x.size()+1];
                             ^

0d51f7eb-98bd-4754-8632-86fafd7d0b29(43): error: this operator is not allowed in an integral constant expression
                 string good[x.size()+1];
                              ^

0d51f7eb-98bd-4754-8632-86fafd7d0b29(43): error: function call is not allowed in a constant expression
                 string good[x.size()+1];
                             ^

0d51f7eb-98bd-4754-8632-86fafd7d0b29(47): error: expression must have a constant value
                 string tab[n], tab2[n];
                            ^

0d51f7eb-98bd-4754-8632-86fafd7d0b29(47): error: expression must have a constant value
                 string tab[n], tab2[n];
                                     ^

compilation aborted for 0d51f7eb-98bd-4754-8632-86fafd7d0b29 (code 2)

Could you tell me what's wrong?

Edited by author 05.04.2008 14:25

Edited by author 05.04.2008 14:26
???
Posted by CHIDEMYAN SERGEY 5 Apr 2008 22:25
#include<string>
Re: ???
Posted by TheDreamCatcher 29 Aug 2011 12:37
#incldude <string>
x.lenght()

Edited by author 29.08.2011 12:37