Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Also ancient dragon could you please re-format the first post .I mean you there are two header files cport.h and xmodem.h along with the comdemo.c file

done

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Can u help me with that?
Probably, but not without knowing how the data was written :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can't return an array of pointers, but you can put all the pointers in a structure an return a pointer to it.

struct sarray
{
    string* words;
};

struct sarray* subordanate()
{
    struct sarray* sa = new sarray;
    sa->words = new string[16];
    sa->words[0] = "when";
    sa->words[1] = "if",
    sa->words[2] = "as if",
    sa->words[3] = "in order that",
    sa->words[4] = "before",
    sa->words[5] = "because",
    sa->words[6] = "as soon as",
    sa->words[7] = "after",
    sa->words[8] = "although";
	return sa;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you are close -- just leave out the i -- do not specify the number of words but let the compiler figure it out from the number of initializers. And BTW this is NOT an array of pointers but an array of std::string objects. There is a huge difference.

string words[] = {
                            "when",
                            "if",
                            "as if",
                            "in order that",
                            "before",
                            "because",
                            "as soon as",
                            "after",
                            "although",
                            "as long as",
                            "since",
                            "unless",
                            "even though",
                            "so that",
                            "while",
                            "not even"
							
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I just got the CD in the mail a few minutes ago, listening to it now. So far its very good.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>char filename[27]="c:\B2B Data\files\file.txt";
your compiler should have issued a lot of error messages about that line. Never ever ignore errors or warnings (in your own code) Most of the time, like the above line, warnings are actually errors waiting to crash your program.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

put the locks in writestring().

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

To use SOCKET you have to include winsock.h when compiling for MS-Windows

>>I feel so noobish. College definitely did not prepare me for my first Software Engineering Job. =X

Now you have the life-long task of really learning. You ain't seen not'in yet :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I downloaded the files in that link but WinZip is not able to decompress then. The files have .tar.tar extension.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

what compiler and os?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Your emergency is not our problem. And we will not do your homework for you. As suggested in that assignment you can solve it with MathLib or some other ways. Why don't you discuss this with some of your classmates ????

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

did you try this tutorial?

Please post a few of the link errors.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Something like this might work: you need std::string with its find() and substr() methods.

read the entire word into one std::string object
start loop
locate a comma
use std::string's substr() to extract the word from position 0 up to the comma
now use std::string's find method to see if it contains a '(' character
if it does, then increment a counter
end of loop

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The value of level is never getting incremented, so after the program executes level--; the value of level is -1. And -1 is not a valid number to use for indexing into arrays or to be passed to validity_check()

Learn to use your compiler's debugger so that you can easily find bugs such as that one. It took me all of about 5 minutes (include compile time) to find it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The way I've broken down the task, I need to take this information off of the file into two int variables (row and cols) and one 2D array (maze[30][30])

You have both missed one important piece of information -- according to the above you must use a 2d array. Both of you are using just 1d array.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you have XP on C: and Vista on D: then you don't have to reinstall anything. Just boot up on XP and reformat the d drive. The only problem I see with that is that you will still have the duel-boot menu. You need to edit the boot.ini file found in c:\ root directory. Here's the one on my computer

;
;Warning: Boot.ini is used on Windows XP and earlier operating systems.
;Warning: Use BCDEDIT.exe to modify Windows Vista boot options.
;
[boot loader]
timeout=30
default=multi(0)disk(0)rdisk(0)partition(1)\WINDOWS
[operating systems]
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /FASTDETECT /NOEXECUTE=OPTIN

Not certain what you have to do to that file to remove the Vista option, but whatever you do make sure you have another copy of boot.ini before editing it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I think you need to count the sentences and words independently -- that is use a different index for each. I didn't compile or test this, but something like this might work.

int sindex = 0; // sentence counter
int windex = 0; // word index

for(int i = 0; i < NumfragmentsInArray; i += 2)
{
     string line = fragments[sindex++]; // sentence1
     line  += words[windex++];
     line += fragments[sindex++]; // sentence2
     line[0] = toupper(line[0]); // capatilize
    cout << line << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Bill Gates ?? think again because he lost that title in January this year when he tried a hostile takeover of Yahoo. Microsoft stock fell 15% and put poor Bill in the #3 spot behind Warren Buffett (now #1) and Carlos Slim Helú from Mexico.

Full article here.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Anyone see where my garbage is?
No -- I keep mine in garbage cans outside my house so that the trash truck can take it away each Tuesday morning :)

Sorry if that was a bad joke. American Idol just started so I have to watch it. Be back in an hour or so to help you if nobody has in the meantime.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You didn't code any function with that parameter. The function you coded takes an array of ints, not an array of std::string. Consequently, in c++, they are two different functions.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You are seeing all that garbage on the screen because the program is printing more array values than what was read from the file. In your example, 30 * 30 is 900, not 10,000, so the loop should stop at 900. You need to save the counter from line 17 so that you can use it as the maximum value in the loop beginning on line 21.

The next big problem with your program is that the entire loop starting at line 17 is wrong. the >> operator stops reading at the first space or at the '\n' character. I guess the lines in the data file can contain spaces since that's what you posted.

The array on line 7 is also wrong. You need a 2d array, ont a 1d array. char array[30][30]; or whatever sice you want to make it. Larger is ok, but too small is disasterous.

// declare array and set everything to 0
char array[50][80] = {0};
int i = 0;
int rows = 0;
int cols = 0;
// read number of rows and columns from the file
mazefile >> rows >> cols;
// read only the number of required rows.  Here we
// can ignore cols because the entire line is read in ad
// a slingle string.
while( i < rows && mazefile.getline( array[i], sizeof(array[i]) )
    ++i;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I guess you mean that you want to append a random number to a string array?

#include <sstream>
#include <string>
using namespace std;

int main()
{
    string s = "Hello World";
    int rnd = rand();
    stringstream stream(s);
    // append the random number to the string
    stream << rnd;
    // display the result
    cout << stream.str() << "\n";
    return 0;
}

>> then sort it
Sort the strings as normal strings, or sort them in ascending order by the random numbers that were appended to the string?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

that error message means that you are attempting to pass a std::string object to printf, but printf() required an integer -- "%d" is an integer, not a string. If all you want is the first character of a string then you need to access it like this: array[i][1][0] , otherwise if you want to pass the entire string then use "%s" and array[i][1].c_str()

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>how we can display the encrypted image
You can't, and that's the whole purpose of entrypting it :) -- the message has to be decrypted first before you can display it so that it makes sense.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

If you are using MS-DOS or MS-Windows you can draw lines draw extended ascii codes See the chart for other line-drawing characters. The other characters will not appear on your screen or show up as small circles/squares because most fonts don't use them for anything.

Simple example:

int main()
{
    char array[80];
    memset(array,205,80);
    array[79] = 0;
    cout << array << "\n";
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>but if some one just give me the basic code, I mean just the start
Ok -- here goes

#include <stdio.h>

int main()
{
    // put your code here
    
    return 0;
}

Before doing anything, learn to read English. That is an absolute must prerequisit. Apparently you have failed to do that because it seems you did not yet read any of the links or comments in any of the previous posts. Writing an operating system is not child's play or someting that a first or second year college IT student would be expected to tackle. Bill Gates didn't even do that -- he bought the original source code from someone at IBM.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

use a program such as Paint to draw new bitmaps then recompile the program ???

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Just watched the iTube movie, with popcorn and diet coke in hand. Some I agree with and some I don't. For example I think its very important that we know what Paris Hilton is up to. How can any American survive without knowing that ? Finally, I don't intend to live my life in fear that the big bad boogyman Ismal will get me at night. If we live like that then they have indeed won. I feel for the families of all those soldiers who died in combat, but I'm not going to stop living my life over it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a pretty good explaination of pair. As its name implies, and that link explicitly states, pair required two objects, not one as you have on line 7 And you can not have the name of the array the same as the class name -- the array name must be something else.

const int student_size = 12;
pair<int,int>* array[student_size];
 for (int i = 0; i < student_size; i++)   	
      array[i] = new pair<int,int>(1,i); // Construct each new pair and give its address to an index in the pointer array

I didn't compile or test the above, so use it at your own risk.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Those errors mean that you failed to declare those two integers in the *.cpp file and without the extern keyword. See my post #2 in this thread.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

1) in line 36 you have to use a different variable than you did on line 22 so that you can compare the two numbers. input >> storeid only reads the store id from the file. In order to read the second store id you have to read all the rest of the line so that the file pointer is moved to the beginning of the next line. getline() will do that for you.

string line;
int num;
while(input >> num)
{
      getline(input, line); // read the rest of the line
      cout << num <<endl;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

you need to declare those variables

#define Value result
extern int Time, Input1;
_inline bool result() {return Time == Input1;}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Yes perheps my memory is faulty :)

I will try to explain the whole scenario what I will do, to get the right picture.
I do have this OneFile.h with this contents only:

#define Value Time == 1800

So, Value does exist in Form3 as a criteria. Now in OneFile.h I have told that
Value is Time == 1800 and this works fine.

Yes that works because it doesn't declare any variables.

What I really want to do in this OneFile.h(which also is my question if it is possible) is to make a bool out of it like:

#define Value result
bool result() {return Time == 1800;}

So result "contains" Time == 1800 in this case.
Is this possible to do in any way ?

When a function is put in a c++ header file its normally called an inline function. If the function is not part of a class then use the inline keyword so that the compiler doesn't attempt to define it multiple times.

#define Value result
_inline bool result() {return Time == 1800;}

To use that in a c++ program:

#include <iostream>
using namespace std;

int Time = 0;
#define Value result
_inline bool result() {return Time == 1800;}

int main()
{
    bool x = Value();
    cout << x << "\n";
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Here is a library and the site has a tutorial how to use it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thanks. Is it not possible to just declare ints, doubles, bools like you do within a Form in this Onefile.h. Like:

int Number100 = 0;
bool Word100 = false;

No, you can't initialize variables in a .h file. and if you omit the extern keyword you will get multiple declarations errors if the .h file is included in two or more *.cpp files.

Why I am asking again is because I can almost be 100% sure about it should be possible because I did this for about 2 weeks ago for a whole day, so I remember it quite well and now when I do it, it does not work.

Your memory is faulty :)

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

because you didn't do it right. google for std::pair and read how to use it.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

What is the class of Display?


error C2061: syntax error : identifier 'pair'
error C2109: subscript requires array or pointer type
error C2227: left of '->Display' must point to class/struct/union

{
	int pair;
    const int student_size = 12;
    pair <int> * pair[student_size]; // Declare an array of pointers to Pair<int>
    for (int i = 0; i < student_size; i++);
    
	{
	pair[i] = new pair<int>(1,i); // Construct each new pair and give its address to an index in the pointer array

	pair[3]->Display(); //since Display is a member function of an object, and pairs[num] is a pointer to that object, you use the arrow operator to dereference and call the member function
	}
	return 0;
	}

delete line 3 because it hids the c++ class by the same name.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

in OneFile.h you have to declare that variable with the extern keyword extern int Number100; Then in one of the *.cpp files int Number100 = 0;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I have a couple of sentences in an array. I need to randomly display 1 of them. How can I do this?

So what would the systax be

char array1[j] = rand () % i;

???

no it is not like that. you do not set the elements of the array to be a number from 0-5, what you want is just to display the string as you said in your original post cout << array[rand() % 5] << "\n"; Note in the above the value 5 assumes you have 5 strings. Replace that with however many strings you actually have in your array.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Lets say you have 5 strings, you need to generate a randome number between 0 and (but not including) 5. Use the mod operator % to accomplish that int num = rand() % 5;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

lines 1, 2 and 3. Current c++ standards do not allow for .h extension for system files. Unless you are using a very old compiler such as TurboC++ then it should be this:

#include <istream>
#include <cstdlib>
#include <fstream>
using namespace std; // optional
using std::cout;
using std::fstream;
using std::ifstream;
// etc

line 35: that's now how eof() works. You don't have to use eof() at all. Note that storeid is undefind in your program. Since storeid in your structure is an int, not a char array, use the >> operator to extract it from the file.

int storeid;
while( input >> storeid )
{

}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>std::cout << fragments << endl;

should be this:
std::cout << fragments << endl;

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

Thanks.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

The code you posted is C, not C++.

/* Reset the original values after we print the result */// printf("%d raised to the %d power is %.0lf\n",parmA,parmB,*powerArgs(&parmA, &parmB));

Sorry, but your version of powerArgs() doesn't raise paramA to the power of paramB. Nor does it return anything so you can't put it in a printf() statement like that.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

why use two different character arrays when you can do it directly in the original, assuming the original is not string literals

char str[] "hello world";
str[0] = toupper(str[0]);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I was unable to access DaniWeb for several hours this morning and for a few minutes again this afternoon -- began experience withdrawl symptoms :) Just me, our lousy wether today, or did you have computer problems?

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You have to know the file format before it is useful to you. The link that stupidenator posted will show you how to use the FILE to read a file, but that is useless if you don't know the details of what the file contains.

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

delete the j loop

Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

right, but you could have written your own little one-line program to prove that for yourself.