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

You cannot write directly to an *.xls file and expect Excel to read it because *.xls files are not plain text files -- they contain a lot of formatting information that is readable only by Excel program.

The easiest way to do it is to creates *.csv files which Excel can import. Fieids (cells) are commma or sometimes tab separated, with CR/LF between each row. Using your example you might write it like this: Text should be surrounded with quotes (see first example below)

myfile << "\"Hello World\"," <<  nums[1] << "," <<  nums[2] << ","  nums[3] << "\n";

or
myfile << nums[1] << "\t" <<  nums[2] << "\t"  nums[3] << "\n";
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

This has got to be the worst job of posting I have ever seen anywhere on the web! If you won't make the effort to post something readable then nobody is going to make the effort to respond to your question. If you don't know how to use code tags please read this thread.

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

Another option you might consider is standard ODBC which will make your program more portable to other compilers should you ever decide to change compilers. There are a number of free c++ ODBC class you can download off the net.

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

that loop will go through all the rows in the file. When end-of-file is reached the loop will stop. To verify that for yourself you can simply print the values on the screen

while( in >> a >> b >>c >>d )
{
    cout << a << " " << b << " " << c << " " << d << "\n";
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

since you know there are 4 numbers on a row

int a,b,c,d;

while( in >> a >> b >>c >>d )
{
  // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

how do you spell -- boring?

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

post one of the rows so we can see what kind of items it has. Generally, if they are all strings (or words). Assuming the name of the stream is in

std::string word;
while( in >> word )
{
   // blabla
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

there are two formas of function getline -- one for c-style character arrays and the other for std::string objects. You are trying to use the incorrect one. Here's what you need:

getline(cin,playerOne);
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>> f the parameter dance is translatable, the function sets instructions to the translation of the dance,

I have no idea what that is supposed to mean. You should have been given clarification in class or in your textbook.

Well, I see from google that it is some sort of game. Sorry, never played it, so it still does not clarify the requirements.

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

I got the same error with Dev-C++ (uses the same compiler). The Microsoft compilers did not complain, but seems to just silently ignore that static keyword.

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

Hm.. Mr. Dragon, I think there is a typo mistake coz the code will not compile. And what the OP wants is "static friend function".

I compiled it with both both VC++ 6.0 and VC++ 2005 Pro, neither complained. But I just now tried it with Dev-C++ and got an error on that line I posted in red. Maybe another famous M$ bug!

Below is a reprint of the example taken from the link to the thread I posted earlier. OP sould read the full text of that link for explaination.

#include "stdio.h"
#include "stdlib.h"

class A;

class B
{
public:
    B();
    ~B();

    static void SetAiPrivate(int value);
    static A *pa;
};

class A
{
friend void B::SetAiPrivate(int);

public:
    A(){iPrivate = 0;}
    ~A(){}
    void PrintData(){printf("iPrivate = %d\n", iPrivate);}

private:
    int iPrivate;
};


A *B::pa;

B::B()
{
    pa = new A;
}

B::~B()
{
    delete pa;
}

void B::SetAiPrivate(int value)
{
    pa->iPrivate = value;
}

int main()
{
    B b;

    B::SetAiPrivate(7);
    B::pa->PrintData();
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Ah I know the answer, he didn't.
Your probably right -- he has not written a function that calls getCount() yet.

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

>>We cannot have static friend function............

who told you that mis-information????

Is below the sort of thing you are talking about? My compilers do not have a problem with static friend. And if you google for "static friend functions" you will find more info about it, such as this thread.

#include <iostream>
using namespace std;

class foo;

class foo1
{
public:
	static friend foo;
	foo1() {x = 1;}
	int getx() {return x;}
protected:
	int x;
};


class foo
{
public:
	foo() {k.x = 2;}
	foo1 k;
};


int main(int argc, char* argv[])
{
	foo f;
	cout << f.k.getx() << endl;
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>int getCount(char word)

that should be like this

int getCount(char*  word)

>>strcmp(p->words,&word)
that won't work either. strcmp() expects a null-terminated string. Just passing the address of word does not make it null-terminated.

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

post the declaration of variable word. It should be

char word[some_value];

or
char *word;
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

12 years old??? you should be skateboarding and hanging out with kids your own age, not saying by yourself if your house at a computer. This is the time for you to be a kid and learn how to socialize with other people.

BTW: unix operating system was written in C.

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

indeed, I have an AK security off fully loaded in my glove department. When I ride an speedbump you better duck.

I mean come on, who has an loaded gun in his glove departement? What happened with to the believe in society?

Depends on where you live. What good is a gun unless its loaded? afterall, you can't soot someone or something with an empty gun, and a rapist or carjacker sure is not going to wait for you to load it.

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

why not just buy a DVD R/W ? I got one a couple weeks ago at Best Buy for about $80.00 (US)

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

I discovered the problem -- there were a couple lines missing in the Windows XP section of grub.conf file.

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

>> char tmp[10];
tmp is too small -- increase to at least 20. Lets say I enter a string of 18 characters, the line tmp[len] = '\0'; will cause program crash.

[edit]Other than the above problem your program seems to work ok. I didn't check every line of the output, but the program spit out a whole bunch of lines.

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

Hi

I am Neera
I am doing my P.Hd in Gender Science :) from the Ohio university
:)

doubtful. you don't even know the correct abbreviation for it, and your spelling is not that of a well-educated person, more like that of a grade-schooler.

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

please edit your post to use code tags per these instructions.

And please post a few of the errors.

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

Update: I discovered how to boot Fedora by setting up the CMOS to boot from the slave driver and then install Fedora on that drive. The computer now boots on the slave drive and displays the grub menu. When Fedora os is selected the computer boots as expected. But when Windows XP os is selected the computer will not boot.

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

>>Technically incorrect. C only supports 1 parameter passback method, pass by value

I'd like you to show us that in the C standards. the term "pass by reference" ( and here) means to pass the address of the object and not a copy of the object. It is not possible to pass an array by value in C or C++ language.

To be fair, I see where you get the idea -- from here, which I think is incorrect.

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

look at the menu options -- there is probably an option to compile for release or debug. You arle probably compiling for relase, which does not contain the information needed for you to single-step through the program.

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

Here is a starter. I would create a structure for the two strings, then array of that structure.

#include <iostream>
using namespace std;

struct states
{
	char *stname;
	char *stabbr;
};

states st[] = { /* State abbreviation*/
"North Carolina", "NC",
"South Carolina", "SC", 
"Georgia", "GA", 
"Florida", "Fl",
"Alabama", "Al",
};


int main(int argc, char* argv[])
{
	int array_size = sizeof(st) / sizeof(st[0]);
	for(int i = 0; i < array_size; ++i)
	{
		cout << st[i].stname << "\t" << st[i].stabbr << endl;
	}
	return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Or are you saying "the cause of many buffer overrun problems is because programmers normally do not pass the size of character arrays."
Yes, that is what I intended to say.

Several standard C string functions have that problem -- strcpy(), sprintf() and gets() are just a few of them.

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

normally do not pass the size of character arrays, which is the cause of many buffer overrun problems.

Its not necessary to always pass a parameter that inticates the size of the array. Example:

int foo( int array[100] )
{

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

I have read several (numerous really) threads but none of them help me. My computer has two huge hard drives. I have Windows XP on the master drive and I want to install fedora 5 on the slave. During the fedora installation there is a window that says grub will be installed in /hda, fedora on /hdb and xp on /hda. Everything seems to install ok, but when I reboot my computer I do not get the boot loader prompt that asks which os I want to boot -- instead the computer boots directly into XP. I tried changing CMOS boot setup to boot from the slave drive instead of the master drive, but after rebooting the computer could not boot at all, so I had to change it back.

Is it really possible to duel boot fedora 5 and XP? Anyone have similar experience?

Thanks

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

I'm not supprised -- it is probably stack overflow problem with all those recursive calls and putting all those huge arrays on the stack. Try putting that array in global memory, outside any function and maybe use a non-recursive algorithm.

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

a) I suspect you are attempting to use 16-bit borland graphics functions with a 32-bit compiler? If not then I have no idea what you mean. You will have to post actual error message(s)

b) a pointer is just the address to the beginning of an array. Of course there is a practical limit on the array's size -- nothing is infinite. But I think what they were saying is that just having the pointer along one cannot determine the array's length. If it is a pointer to a string then you can call strlen() function to get its length, but the array size can larger.

Example:

int foo( char * pointer)
{
  return strlen(pointer);
}

int main()
{
   char name[255] = "Jones";
   int len = foo(name);

   return 0;
}

In the above code function foo() returns the length of the string but has no clude about how big the array of characters.

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

that is the desired way of doing it, but there is nothing to enforce that rule.

>>passing the array's length will stop error of reading off the end of the array

only if the function uses that value for error checking. If the function has no error checking then passing the array size does nothing at all.

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

Welcome -- we are happy to help all programmers regardless of your major in college. All you have to do is ask a lot of questions and post code that show problems.

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

If you are talking about true MS-DOS than it is not possible because MS-DOS is not a multi-tasking operating system. When your program runs there will be no other programs running on the computer.

If your computer is running any version of MS-Windows then you will not be running MS-DOS, but just an emulator which is itself just another MS-Windows program.

>>Basically, I need to write another external program that shows me all the files actually open in the system, and what program is accessing them...

As far as I know it is not possible to do that. The number of files that can be open at any one time is somewhere in the thousands under MS-Windows. The old MS-DOS limit of 15 files has been tossed to the wind several years ago.

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

I thik below is the correct implentation of that class. One problem with this implementation is that the class is attempting to manage a list of objects that it does not own, and if some other function decides to delete one of the objects it will invalidate the pointer in the stack class. This can potentially cause a lot of grief, cursing and hair pulling by the programmer.

You will want to add some error checking in the push and pop functions to make sure variable current is within range.

class stack { 
private:
	int top; 
	int current;
	void *layer[100]; 
public: 
	stack(void)
	{
		top=0; 
		current=0;
	}
	int push(void *myobject)	{
		layer[current++] = myobject;
		return current-1;
	}
	void* pop(void) 
	{
		return layer[current--];
 
	}
};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>hey,, i'm joyce, newbie

Welcome to DeniWeb. Please go to the CoffeeHouse and tell us about yourself.

As for your problem if it were me I would convert the integer to a character string then just print the string backwards. You can use sprintf() to make the conversion.

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

>>It's bad form
matter of opinion, not fact. I hate it when programs leave all that irrelevant crap on the screen that hides what I need to read. If there is no reason for it to be there I would rather see it erased.

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

Although that may be true, the problem is how to determine which byte on the stack is the return value?

>>How about surtracting the return value of the procedure and the return value of the next procedure (which would be above the 1st one in the stack). Will that work ?

No because the contents of the stack are dynamic not static so the contents of the next procedure call are not even on the stack.

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

you can use precompile directives

#if defined(_WIN32)
system("cls");
#else
system("clear");
#endif
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

depends on the operating system. The simplest way is to call system() function with the os-dependent command.

MS-Windows:

system("cls");

*nix

system("clear");

Others: I have no idea

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

the stack frame size is not fixed -- it depends on the parameters passed to the function, and whether the parameters are pushed onto the stack or passed in registers. Read the link -- it gives a much better explaination. What you are attempting to do in your original question just simply is not possible.

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

If that's what he wants, then its pretty small and depends on the processor and sometimes the compiler. Here is an example of how the compiler generates the startup code for a function on intel processors. Other processors will be different.

push sp
push ebp
push esi
push edi
mov bp,sp
sub sp,<size of local variables>
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

see sizeof() operator -- but the size of a pointer is always the same on 32-bit compilers.

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

first learn to open a file using fopen(), read a line from the input file using fgets() and write the same line to the output file using fprintf(). Once you can do that, come back and talk about how to actually split the file into two or more files.

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

>>pst = (A*)malloc(sizeof(A)*1);

1. The "*1" is unnecessary and spurious.
2. C programs do not require typecasting. So remove that typecast. If your compiler complains then your are apparently writing a c++ program.

3. Move that structure above the functuion main() so that it is visible to all other functions. Then change function1 parameter to use that structure instead of passing a void pointer. You will need to change the function prototype at the top of your program too.

void function1(A *pStr)
{
  // blabla
}

4. Come up with a better naming convention than "A". That is a sure sign of poor programming habits. You are new at this, so learn the right way at the very start.

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

I get similar error sometimes if I did not include the correct header files and something has not been defined. DaniWeb does not allow us to use our crystle balls to see your program so I you will just have to post it.

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

your program is using non-standard Borland (I think) graphics functions so you might be on your own with this program.

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

>>scanf ( "%s", &rainfall );

%s wants a character array of at least 2 bytes. rainfall is not a character array, so the above will always fail to work correctly.

char rainfall[2]; // 1 byte for either Y or N and secnd byte for null terminator
scanf ( "%s", &rainfall );

There are probably other problems, but I stopped reading after that line.
[edit]barometer has the same problem. Where do you declare variables storm etc ? Post them too.[/edit]

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

I don't know a thing about it, but did you check google?

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

>> Date.obj : error LNK2028: unresolved token (0A00028C) "public: __thiscall Date::Date(class Date &)" (??0Date@@$$FQAE@AAV0@@Z)

The above error (and similar other ones) is telling you that you forgot to code one of the Date constructors. If you look in Date.h you will find that it has two constructurs -- but in Date.cpp only one of them was coded. You need to implement the missing one.