Score:0

A tricky matter in Geany

in flag

I typed these code in Geany:

void copy_fct()
{
    int v1[10] = {0,1,2,3,4,5,6,7,8,9};
    int v2[10] = {0,0,0,0,0,0,0,0,0,0};
    // to become a copy of v1
    
    for(auto i=0; i!=10; ++i) // copy elements
        v2[i]=v1[i];
    // ...
}

while, when I compiled it, there was always a red wave line under "int v2[10]", I tried "int v2[] = {0,0,0,0,0,0,0,0,0,0};" "int v2[];" and "int v2[10] = {};", all the same, I tried declared v2 outside "copy_fct()", it was OK, but, if I do want to declare it inside "copy_fct()", is there a declaration here without descend the warning level (now is default "Wall")?

The whole code was:

#include <iostream>
using namespace std;

int main()
{
    std::cout<<"Hello,World!\n";
    }
    
bool accept3()
{
    int tries = 1;
    while(tries<4){
        cout << "Do you want to proceed (y or n)?\n"; // write question
        char answer = 0;
        cin >> answer; // read answer
        
        switch(answer){
            case 'y':
                return true;
            case 'n':
                return false;
            default:
                cout << "Sorry, I don't understand that.\n";
                ++tries; // increment
            }
        }
        cout << "I'll take taht for a no.\n";
        return false;
    }

void copy_fct()
{
    int v1[10] = {0,1,2,3,4,5,6,7,8,9};
    int v2[10] = {0,0,0,0,0,0,0,0,0,0};
    // to become a copy of v1
    
    for(auto i=0; i!=10; ++i) // copy elements
        v2[i]=v1[i];
    // ...
}
mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.