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

Use the modular operator, which will return a value between 0 and maxNumber. int x = rand() % maxNumber;

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

Of course looks mean nothing if the program doesn't do anything but display a pretty picture.

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

Depends on the operating system. But here is a tutorial for MS-Windows.

There are easier ways to create GUI windows. One of them is C#, while another is using c++/CLR and VB.NET. c++ is not a good language for that purpose although it can be done quite successfully (and a whole lot of work on your part).

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

If you are attempting to display the file size then you are formatting the string with the wrong value. stat() doesn't return the file size, but it returns 0 if the file's stats were successfully retrieved, or non-zero on error. The file size is contained in struct _stat.

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

But he wants it for the computer, not the iPhone... :D

How can you tell that code is for iPhone?

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

Just like C and C++ you have to prototype the functions that you want to call. That function "rad" does not appear anywhere in that file except the call statement.

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

what is that write function that you posted? It's not standard C or C++.

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

If you are using Microsoft VC++ 2008 Express (or some other edition of that IDE) then you have a couple choices. If you have used 3d party libraries in your programs before, then this will be no different than that.

1) use the pragma #pragma message(lib , "somefile.lib") near the top of your program, but after all the include files.

2) Add the name of the library to Project --> Properties --> Configuration Properties --> Linker --> Input..

3) If you are using LoadLibrary() then you don't have to do either of the above two opeions.

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

How to fix you broken computers

http://www.youtube.com/watch?v=PFcL6hiyyuc&NR=1

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

If all you want to share is a header file and *.cpp file then I wouldn't bother making a DLL because that is like killing a fly with a sludgehammer. Instead, just create a static library project and add those two files to it. Then in each of the application programs just link with that library.

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

I though you said the company already gave you the DLL???

the company has provided me with a
header file and lib file and ofcourse the dll file

So why are you trying to recompile it? Just use the DLL that they gave you. Write your program, include their header file, and link with their library. Put their DLL in the same directory as the program you wrote and you have it all done. Nothing different about that then there is using DLLs provided by the compiler.

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

First Thanks for your kind assistance.

Maybe I posted in the wrong spot I am sorry. I thought this was a place for the amateur to ask questions, which I am. I am trying to learn.

DaniWeb is a place where people can learn.

I thought first if I could just get the math to work but it is apparent I need to study more.

There isn't much math involved, at least for the problem you posted. It's mostly logic thinking and learning how to make a C or C++ program do what you want it to do. Just like math, you can't do calculus if you have not yet learned how to add, subtract, multiply and divide. You have to start at the beginning, not somewhere in the middle. Buy yourself an Introduction to C++ programming book and start studying it from page 1, doing all the exercises at the end of each chapter. There is a Read Me thread at the top of this forum that has many excellent book suggestions.

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

Dragonmeister!?!?! getche() ?!?!? getchar() please. It's at least standard...

There is very little about Turbo C that is standard, so it doesn't make any difference whether he uses getche() or not. Could also do this without a problem

while( !kbhit() )
    delay(100);

That's not standard either, but works in that old crappy compiler.

nbaztec commented: Couldn't agree more. Wish, could +rep > 1 :) +1
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

> this is not homework but rather my work
I'm shocked that someone with a programming job can't solve this trivial problem :-O

I'm not after reading this thread.

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

If this is part of a c++ class then make those two variables members of the class. If not, then you can declare them in main() and pass them around to the functions that use them. In the case of the function you posted, you will have to pass them by reference to that function so that that function can change their values.

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

assert() only shows something when the program is compiled for debug. If compiled for release assert() does nothing. In your example it is better to test for inFile.is_open() , which works in both debug and release mode compiles.

int main()
{
    ifstream inFile;
    ofstream outFile;
    inFile.open("file.txt");
    if( !inFile.is_open() )
    {
          cout << "File not opened\n";
          return 1;
    }
    cout << "everythings fine" << endl;
    cin.ignore();
    cin.get();
    return 0;
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>will you please help me about Turbo C?

Turbo C/C++ is a real real old, and an ancient compiler!

Yes we know, but I think his school requires it. :@

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

>>when I tried to run it, it suddenly closed

That's because there is nothing at the end of main() to prevent that behavior. If you want it to stay open so that you can see it, then add getche(); at the end of main(). The program will then stop until you hit a key.

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

system()
Cmd Clear

you mean system("cls") on MS-Windows or system("clear"); on *nix computers. That erases everything on the console screen, does nothing for program's variables. And that I NOT probably what Salem was talking about.

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

Here's how to use it

#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>

using namespace std;

int main()
{
    const int QA = 10;
    string  question[QA] = {"Q1", "Q2", "Q3", "Q4", "Q5", "Q6", "Q7", "Q8", "Q9", "Q10", };
    string name1, name2;
    int choice;

    cout << "Enter Name1: ";
    cin >> name1;
    cout << "Enter Name2: ";
    cin >> name2;
    random_shuffle(&question[0], &question[QA-1]);
    for(int i = 0; i < QA; i++)
        cout << question[i] << '\n';

    system("PAUSE");
    
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You can use c++ ramdom_shuffle() to scrample the names. I have not used it myself so can't tell you how to do it.

The rest of that program should be pretty straight forward.

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

Delete it and install a better compiler such as Code::Blocks or VC++ 2008 Express. I know they both work ok.

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

What are the problems with that program? You don't take your car to an auto shop and tell them "My car is broke, please fix it" :) You have to at least tell them what the problem is.

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

I think you might be talking about an array of pointers to some objects, and the pointers are NULL if it does not contain valid pointer. Something like this:

class MyClass
{
   // blabla
};

// an array of 10 pointers to MyClass objects, 
// initialized to NULL pointers.
MyClass* array[10] = {NULL};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

No you don't call it -- but you do have to write the implementing code for it, something similar to the way you write implementing code for the other class methods.

CAccount::CAccount()
{
    // initialize class variables here
}

>>I dont really understand because I put the constructor in both classes
I see CAccountList() constructor but not CAccount().

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

What difference does that make? If your computer has enough ram then it shouldn't matter how big (or small) the compiler is.

You might have to send them an email asking them how to do it.

I installed CFree a few minutes ago after reading your post here, created a Windows Dialog program, tried to compile it with MinGW compiler, and it failed. I've sent them an email asking what's wrong. I also suggested they add a forums to their web site so that we can post there instead of sending emails. **sigh**

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

CFree uses MinGW compiler, which is a 32-bit compiler. Therefore you can not use graphics.h or its library with that compiler. As for OpenGL, just install it on your computer then set up CFree to use it. I have never used CFree, but from its home page and description it might be a stripped-down version of Code::Blocks.

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

>>undefined reference to `cAccount::cAccount()'

That means you defined a constructor in the class but never coded the implementation function.

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

Oh so it's D3D10CreateDeviceAndSwapChain() that can not be foud, not initD3D() -- my mistake. But the same suggestions still apply. According to this microsoft link that function is in D3D10.dll (scroll down to the bottom of the page and it will tell you what library it's in.)

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

>>but what does that mean?

Search the tutorial that you are using for that function. Must be there somewhere. If not then you are using the wrong tutorial.

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

1) include stdlib.h and use _MAX_PATH macro to declare the size of the source and destination buffers. On MS-Windows its value is 260. In c++ programs it will be better to use std::string variables instead of char arrays. If you do that then you don't need stdlib.h.

line 21: The file is opened in binary mode. getline() works on files opened in text mode. either change the open methos (not recommended) or call read() instead of getline().

line 22: file b has not been opened. If the input file is opened in binary mode then the output file should also be opened in binary mode, and use write() instead of << operator which is for files opened in text mode.

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

char *mon;
mon is a character pointer variable.
Is there any problem with the declaration?

strncpy() does not allocate memory for the destination address, that has to be done by the calling function. So you might want to declare it like this: char mon[255] = {0}; . That allocated enough memory to store 255 characters in that buffer. Change that number to whatever you think will be needed. It will also initialize each of the bytes to '\0';

Narue commented: And my attempt to get the OP to actually use his brain is now wasted effort. Arigatou gozaimashita. -4
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Also initD3D is a user defined functio
I assumed that was in a library. But if not then look at our own code for that function. google found this tutorial that contains that function

>>I tried dumpbin.exe d3d10.lib in the command and I get a huge list of ... things?

Surprise! redirect output to a file, load it with Notepad, and search for what you want.

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

In the same folder as the compiler there is a program named dumpbin.exe. ( use a command prompt do run that file. You might also first have to run vcvars32.bat to set paths) It will list all the public symbols in a library. Run it against the library to see if it contains initD3D function and if it does was it's name mangled the same way your compiler mangled it.

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

hi....... i want a program in c based on any data structures with de code.plz............it shd be catchy n can be based on reality

And you should learn how to write proper English instead of that baby googoo gaagaa talk. That's what's wrong with kids these days -- cell phones and texting have destroyed their ability to write.

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

You still failed to declare those two arrays as I showed you. Also problems in Change() function. main() returns an int, not void.

int main()

{

    char str[20]= {0};
    char enc[20] = {0}; 
printf("enter a string...");

gets_s(str);
Change(str, enc);
printf("%s",enc);


}




void Change(char *source, char *dest)
{

char *s;
char *d;
int i;
d=dest;
s=source;


for (i=0;source[i];i++)  
{
if(RLE (dest, source[i])==0) 
{
*d=source[i]; 
*(++d)=(RLE(source, source[i]))+'0'; 
d++;
}
}
}
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I've toyed around with that some time ago too, trying to see what happens when main is declared to return char*. My compiler just returned the address of the string, which is an integer.

Similar with void main() . In this case the compiler produced code to return whatever value was already contained in the ax register, an integer in C language (assuming Intel-based processor PC such as . MS-Windows and *nix).

So regardless of how you declare main() the compiler will produce the code necessary to return an integer or the compiler may just produce an error and not generate any code at all.

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

The problem is that you did not clear out the destination buffer when you declared it

char str[20] = {0};
char enc[20] = {0};
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

>>Plants plant1();

When declaring an object do not include the (). Its just Plants plant1;

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

>>Is there a way through which i can clear all the inputs at the end of loop..

while( kbhit() )
   getche();
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

I agree its stupid thing to do, unless of course the wrapper function does other things too.

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

Yes of course its possible. How to do it will depend on the file's format. Not all images are equal. Here are some links for you to research.

Salem commented: Well said, and nice link ;) +19
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster

You will want to use a two-dimensional array for that -- the first dimension is the distance and the second dimension indicates whether there is a car in that spot or not. So you will want to declare the array something like this:

const int MaxParkingSpaces = 10;
int ParkingSpaces[MaxParkingSpaces][2] = {0};

Next you will need to fill the first dimension with the distances you want.

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

Its very possible that on line 25 the value of size will be 0. new can handle that ok but will return a pointer to a zero length string and line 25 will trash memory when that happens.

>>//inserts b inside a from index m to n

I don't think that's going to happen because m and n are the same value according to line 14.

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

The code I posted above works.

Other problems: One reason your program is not creating the files is because you are leaving some files open and then attempting to use the same fstream object to open the file again. You need to call file.close() then file.clear() before attempting to call file.open() again. That is the case in function Tran().

Make it a habit to close files immediately when done writing (or reading) to them.

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

For starters, readKeyb() has several problems. It should be calling getline() to get strings that may contain spaces, such as addresses. And you need to remove the '\n' (Enter key) from the keyboard buffer after entering numeric data.

void readKeb (tempt stdrec[], int x)
{
	for(int i=0; i<x; i++)
	{
		cout << "enter student " << i+1 << " record: " << endl;
		cout << "----------------------------" << endl;
		cout << "First Name: "; cin >> stdrec[i].name.first; cout << endl;
		cout << "Last Name: "; cin >> stdrec[i].name.last; cout << endl;
		cout << "ID: "; cin >> stdrec[i].id; cout << endl;
        cin.ignore(); // remove '\n' from keyboard buffer
		cout << "Telephone: "; cin >> stdrec[i].tel; cout << endl;
        cin.ignore(); // remove '\n' from keyboard buffer
		cout << "Address: "; getline(cin,stdrec[i].add); cout << endl;
		cout << "Grades: ";
		for(int j=0; j<5; j++)
		{
			cout<<j+1<<") ";
			cin >> stdrec[i].grade[j];
		}
        cin.ignore(); // remove '\n' from keyboard buffer
	}
}

function copyfile() -- rename the print.xls to something else because you are not writing the contents of the file in .xls format. I'd suggest you name it print.csv.

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

I have Win7 and using FF with Logitech wireless keyboard and mouse. The problem is that the mouse wheel stopped working (it won't scroll the window any more, or just scrolls intermittently for very short periods of time) but everything else works as expected. Changed the battery but that did not help.

Any other ideas now to fix the problem?

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

Sure potential is an important quality, but would you hire a dull person
to make a software for you company, even if that dull person has
potential? Or would you hire a "*smart" person for that same job?
Remember its you ass on the line.


------------------------------------------------------------------------------------------
* whatever smart means these days.

Depends on how smart he/she is -- If too smart he might get bored with his job pretty quickly and move on to some other place where the grass may be greener. I wouldn't count on such a person except for the short term.

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

If you are using VC++ 2008 or Code::Blocks those IDEs will generate some of the DLL code for you. Then all you have to do is add the functions you want, declare then with __dllexport (or add the function name to a *.def file). You can even export entire c++ classes using __dllexport.

One thing to keep in mind -- any memory allocated in the DLL must be deallocated in the DLL. The calling application program can not deallocate it. The same with memory allocated in the applicaton can not be deallocated in the DLL.

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

line 420: open() takes const char* but you are passing std::string. change it like this: outfile.open(filename.c_str());