עבור לתוכן

עזרה בבדיקת קוד (אין שום סיבה ערורה בעולם שזה לא יעבוד !*!)

Featured Replies

פורסם

שלום, אני איש מעוצבן שלומד\(מתמודד עם הקושי) שפת ++C (התחלתי לאחרונה להיות מעוצבן..)

אני בונה מיני משחק שתוך כדי בנייתו אני לומד את כל האספקטים של השפה (ממ.. כן.. את רובם..)

למעשה הקוד מובא הישר מספר (!) אשר רכשתי בכדי לעזור לי לא להתפגר מוקדם מידי תוך כדי הלימוד..

הקוד הוא כזה:

#include <iostream>

int main()
{
std::cout << "Decryptix. (C)Copyright 1999 Liberty";
std::cout << "Associates, Inc. Verion 0.2\n " << std::endl;
std::cout << "There are two ways to play Decryptix: ";
std::cout << "either you can guess a pattern I creat, ";
std::cout << "or I can guess your pattern.\n\n ";

std::cout << "If you are guessing, I will think of a\n ";
std::cout << "pattern of letters (e.g., abcde).\n\n ";

std::cout << "On each turn, you guess the pattern and\n ";
std::cout << "I will tell you how many letters you\n ";
std::cout << "got right, and how many of the correct\n ";
std::cout << "letters were in the correct position.\n\n ";

std::cout << "The goal is to decode the puzzle as quickly\n ";
std::cout << "as possible. You control how many letters\n ";
std::cout << "can be used and how many positions\n ";
std::cout << "(e.g., 5 possoible letters in 4 positions) \n ";
std::cout << "as well as whether or not the pattern might\n ";
std::cout << "contain duplicate letters (e.g., aabcd).\n\n ";

std::cout << "If I'm guessing, you think of a pattern\n ";
std::cout << "and score each of my answers.\n\n " << std::endl;

const int minLetters = 2;
const int maxLetters = 10;
const int minPositions = 3;
const int maxPositions = 10;

int howManyLetters = 0, howManyPositions = 0;
bool duplicatesAllowed = false;
int round = 1;

std::cout << "How many letters? (";
std::cout << minLetters << "-" << maxLetters << "): ";
std::cin >> howManyLetters;

std::cout << How many positions? (";
std::cout << minPositions << "-" << maxPositions << "): ";
std::cin >> howManyPositions;

char choice;
std::cout << "Allow duplicates (y/n)? ";
std::cin >> choice;

return 0;
}

WTF is wrong with this piece of shit?!*

אני לא יודע מה לא בסדר עם זה, זה אמור לעבוד חלק כמו יפני שבונה קונסולה !

אני מתייאש מרגע לרגע.. זה הקוד שהקלדתי הישר מהספר איך יכול להיות שיש בו באגים?! או טעויות כלשהן?!

אשמח לעזרתכם בנושא (ועוד איך אשמח..)

תודה :)

פורסם

תנסה להוריד את הSTD::

ולשים use namespace....

עריכה:

חסר לך " באחת השורות שם.

פורסם

באיזה קומפיילר אתה משתמש ומה השגיאה שאתה מקבל?

פורסם
  • מחבר

ראשית תודה על ההיתיכסות :)

עכשיו לעסק..

Ghosthunter, ניסיתי את מה שאמרתה ההצעה הראשונה עם ה using namespace std;

ומספר השגיעות נשאר אותו הדבר, אך הקוד נראה מסודר יותר :cool2:

בקשר להצעה השנייה עם ה iostream.h זה רק הכניס לי עוד ERRORים.. :nixweiss:

Boomerang, אני משתמש בקומפיילר של Microsoft השם המלא (Microsoft Visual C++ 6.0)

והשגיעות הם להלן:

--------------------Configuration: Decrypix - Win32 Debug--------------------
Compiling...
Decrypix.cpp
g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2065: 'How' : undeclared identifier
g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2146: syntax error : missing ';' before identifier 'many'
g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2065: 'many' : undeclared identifier
g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2146: syntax error : missing ';' before identifier 'positions'
g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2065: 'positions' : undeclared identifier
g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2001: newline in constant
g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(43) : error C2146: syntax error : missing ')' before identifier 'cout'
Error executing cl.exe.

Decrypix.obj - 7 error(s), 0 warning(s)

ואם לא מבינים מזה שום דבר אז הינה עוד אחד:

--------------------Configuration: Decrypix - Win32 Debug--------------------

Compiling...

Decrypix.cpp

g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2065: 'How' : undeclared identifier

g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2146: syntax error : missing ';' before identifier 'many'

g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2065: 'many' : undeclared identifier

g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2146: syntax error : missing ';' before identifier 'positions'

g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2065: 'positions' : undeclared identifier

g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(42) : error C2001: newline in constant

g:\microsoft visual studio c++\msdev98\myprojects\decrypix\decrypix.cpp(43) : error C2146: syntax error : missing ')' before identifier 'cout'

Error executing cl.exe.

Decrypix.obj - 7 error(s), 0 warning(s)

תודה על העזרה עד כה :xyxthumbs:

פורסם

יש לך " ששכחת שם.

פורסם
  • מחבר

איפה שם ?*!?

תודה על שאתם ממשיכים להתקשות יחד איתי :smile1:

פורסם

בדיוק בשורה שהוא אומר לך שיש שגיאה אולי ?!?!?!

std::cout << How many positions? (";

תשנה ל

std::cout << "How many positions? (";

פורסם
  • מחבר

אההה.. שם חסר " .. הבנתי..

WTF!*!#!#*!@#!#*$*^ אני לא מאמין שעל זה ישבתי ערב שלם בניסיון להבין מה הולך ולמה אני מתקשה!*!

הטעות הכי קטנה מסתברת כהכי גדולה בעסק הזה.. סה"כ * " * אחד.. ו-7 ERRORים...

טוב עכשיו אני רגוע, הDebug הזה באמת יכול לעזור בזמנים קשים שכאלו, אני חושב שאתייכס אליו יותר ברצינות מהיום והלאה.

תודה רבה רבה רבה על עזרכתם !!! :xyxthumbs:

*I'll be back with more hardening problems in the future

so expect to more releases of "I'm nervous and desperate, pleaes help me will ya" :smile1:

פורסם

DEBUG זה בעת הרצה לאחר קימפול ולינקיזציה. מה שנתן לך הודעות שגיאה זה הקומפיילר.

ובאמת כדאי להקשיב לו, ולסדר לו אפילו ורנינגים כדי שהדיבאג יהייה פשוט יותר אחר כך.

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

דיונים חדשים