我不确定是什么导致了这一点,我在谷歌上发现的是忘记在我的结构末尾的分号引起了这个,但我有一个.
这是代码的一大块......
#include <stdio.h>
#include <string.h>
#define NAME_LENGTH 20
#define BOOK_NAME_LEN 50
#define AUTHOR_NAME_LEN 30
enum bookStatus {CHECKED_IN, CHECKED_OUT, UNDER_REPAIR, LOST}
enum patronStatus {ACTIVE, INACTIVE}
struct Book{
char title[BOOK_NAME_LEN];
char author[AUTHOR_NAME_LEN];
enum bookStatus status;
};
struct Name{
char first[NAME_LENGTH];
char last[NAME_LENGTH];
};
struct Patron{
int numBooksOut;
struct Name name;
struct Book books[50];
enum patronStatus status;
};
struct Collection{
struct Book book;
char title[BOOK_NAME_LEN];
char author[AUTHOR_NAME_LEN];
int id, year;
enum bookStatus status;
};
struct Library{
int totalPatrons, totalBooks;
struct Patron patrons[50]; …Run Code Online (Sandbox Code Playgroud) 我基本上采用了一大块字符并使用每个后缀作为键,每个键指向一个ArrayList,其中包含可以找到每个后缀的索引.
当我做一个HashMap.get(后缀)时,它给我最后添加的键的索引,而不是我想要拉的那个(这在重复上发生...
这里是,
protected HashMap<String, ArrayList<Integer>> makeMap(char[] textStored)
{
HashMap<String, ArrayList<Integer>> phraseMap =
new HashMap<String, ArrayList<Integer>>();
ArrayList<Integer> indexList = new ArrayList<Integer>();
Boolean word = true;
String suffix;
int wordEndIndex = 0;
for (int i = 0; i < textStored.length; i++) {
word &= Character.isLetter(textStored[i]);
if (word) {
for (int h = i + 1;h < textStored.length;h++) {
if (!Character.isLetter(textStored[h])) {
wordEndIndex = h;
break;
}
}//PULLING THE NEXT SUFFIX vvv
//This finds the next word/suffix:
suffix = new String(textStored).substring(i,wordEndIndex + …Run Code Online (Sandbox Code Playgroud) 我们的任务是拥有服务器 - 客户端模型....
我们应该检查命令行arg,如果没有(argc = 1),我们设置为服务器.否则我们使用argv [1]来设置客户端套接字......
如果我只是为参数使用随机性似乎运行正常,但是当我尝试将地址放入1.2.3.4时,它不会给出任何输出,只是启动程序而什么都不做.
我想我的问题是以IP地址的形式处理命令行参数的最佳方法.
这是我的主要功能.
int main( int argc, char *argv[] )
{
printf("%i",argc);
if(argc==1)
{
printf("Welcome to the ZOG Virtual Probe Game! You have choosen to take the role of a server.");
printf("\nPlease wait for an opponent to connect.");
runServer();
}else if(argc==2)
{
printf("Welcome to the ZOG Virtual Probe Game! You are now connecting to specified IP.");
runClient(argv[1]);
}else
{
printf("You used an invalid command line argument. You can input an IP address or …Run Code Online (Sandbox Code Playgroud)