简体   繁体   中英

How do I create a loop in omnet++?

How do I create a loop in omnet ++ with a user defined variable. I tried the following but it gave me an error: network Network{

  parameters:

        int n @prompt("enter number") = default(2);

    connections:

        for i=0..n do { // here the n gives me a syntax error (unexpected NAME, expected { 
            //do things

        }   

Have a look at the OMNeT++ manual . The for syntax is without do , eg

for i = 0..count-2 {
        node[i].port[1] <--> node[i+1].port[0];
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM