小编dia*_*t66的帖子

C错误:数组类型具有不完整的元素类型

我正在尝试在Ubuntu 11.04中编译一个在Windows中运行良好的程序,但它会出现上述错误.我在导致错误的行中添加了注释.这是代码:

route_input() {
    int num_routes;//Variable to act as the loop counter for the loop getting route details
    int x;

    char route_id[3];
    char r_source[20];
    char r_destination[20];
    int r_buses;



    printf("Please enter the number of routes used: \n");
    scanf("%d", &num_routes);
    char routes_arr[num_routes][10];//An array to hold the details of each route

    printf("\nNumber of routes is %d\n", num_routes);

    struct route r[num_routes];//An array of structures of type route (This line causes the error)

    fflush(stdin);

    for (x = num_routes; x > 0; x--) {
         printf("\nEnter the …
Run Code Online (Sandbox Code Playgroud)

c ubuntu gcc struct

3
推荐指数
1
解决办法
1万
查看次数

如何让Java线程始终在另一个线程之前运行?

在我的程序中,当用户输入一个号码时,程序通过套接字将该号码发送到服务器,服务器发回与该号码匹配的数据.该数字代表服务级别.具有IncomingReader()实例作为其runnable的线程然后读取从服务器发送的内容,并将其存储为arraylist(详细信息).然后,我使用详细信息arraylist中的数据创建类MyClients的对象.我的问题是创建对象的循环在从服务器读取数据的线程运行之前运行.如何在创建对象的循环之前使从服务器读取的线程运行?代码如下:(我为了简洁而删除了GUI的代码)

public class SearchClients {

JFrame frame;
private JTextField textField;
private JTextField textField_1;
private JTextField textField_2;
private JTextField textField_3;


BufferedReader reader;
PrintWriter writer;
Socket sock;

 static ArrayList<String> details = new ArrayList<String>();

public static void main(String[] args) {
    EventQueue.invokeLater(new Runnable() {
        public void run() {
            try {
                SearchClients window = new SearchClients();
                window.frame.setVisible(true);
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
    });
}

public SearchClients() {
    initialize();
}

private void initialize() {

    setUpNetworking();
    Thread readerThread = new Thread(new IncomingReader());
    readerThread.start();


    JButton …
Run Code Online (Sandbox Code Playgroud)

java static multithreading static-members thread-safety

-1
推荐指数
1
解决办法
1334
查看次数

标签 统计

c ×1

gcc ×1

java ×1

multithreading ×1

static ×1

static-members ×1

struct ×1

thread-safety ×1

ubuntu ×1