How to declare a string outside the function but define it's size inside?

1
2
3
4
5
6
//HERE!
int main(){
   int N = 6;
   char S[N]; //I don't want this here, but up there (where "HERE!" is)
   return 0;
}

I could just do:
1
2
3
4
5
6
char* S;
int main(){
   int N = 6;
   S = new char[N];
   return 0;
}

But I want this to do without dynamic memory (Don't ask why).
Is there a way?
closed account (Dy7SLyTq)
you can do it c-style: extern S[]
Topic archived. No new replies allowed.