>>Contest details will be announced soon.
What's the current status of this contest? It's been 7 months and have not heard anything about it, or maybe I just missed it.
>>Contest details will be announced soon.
What's the current status of this contest? It's been 7 months and have not heard anything about it, or maybe I just missed it.
Class definitions are normally put in header files, which are included in the *.cpp file. This is done do that the class can be used anywhere within the program, not just main(). Right now you are probably writing very simple programs that contain only a main() function. What would you do with a program that has hundreds or even thousands of functions? You can't (or don't want to) define the same class over, and over for hundreds of times at the beginning of each function that needs it.
Correction: vector<string> Players::info;
make the vector static.
class Players{
public: static vector <strings> info
};
Then in one of the *.cpp files declare it again as if it were a global variable
// Players.cpp
#include "Players.h"
Players::vector<string> info;
A 2d array might look something like this: Note that it has 2 asterisks, not just one.
double **array = new double[rows*sizeof(double*)]; // allocate the rows number of pointers
for(int i = 0; i < rows; i++)
array[i] = new double[cols]; // allocate columns for each row
matrix is a 1d matrix, not a 2d matrix. You can keep it as a 1d matrix if you want to but that means you have to calculate the row and column index yourself.
This is one of the rare times I could start the i counter with 1 instead of 0 so that the calculation (i-1) does not become a negative number. And this needs two loops, not one.
for (int i=1; i<= rows; i++)
{
for(int j = 0; j < colums; j++)
cout << matrix[((i-1) * rows) + j];
}
>>skip 16bit it is dead
Skip 16-bit programs yes, but you still have to know about 8 and 16 bit assembly instructions because they are still relevant in 32 and 64-bit programs, especially the string instructions.
I assume you mean 64-bit processors. The answer is yes because they are still in the x86 family of processors. Intel didn't completly replace the 32 and 16-bit processors, they added to them. 64 and 32 bit processors still use the 16 and 8 bit processor instruction set.
>>Is there any quick way i can do a goto line without seeking through the whole file or is that asking too much?
Depends. If it is a file that you want processed only once, then the answer would be no. But if you need to process the file multiple times either in the same or different sessions then maybe. What I have done in such cases is to create an index file that contains a key field and offset to that line in the original file. This index file is much smaller than the original cvs file, can be sorted after it is created so that your program can use binary search techniques on it (assuming the key file is a binary file). If you don't want to do that then the only alternative I have is to read the whole file serially until you get to the desired line.
Yes, I'm starting a little early. Just finished off a bottle of extra-dry Champagne spiked with brandy. I had glasses for Dani, Narue. and Davy. I hope you liked it cause I sure did :)
31 Dec is also my last day at Wal-Mart. I decided to enjoy life for once. Want to visit Australia and visit the world's largest zoo, as well as some sights around USA.
Wish everyone at DaniWeb happy New Year :)
>>And I also know that it's not allowed to declare functions in headers unless they are inlined
Wrong -- see your second example.
>>Will it still be inlined?
No (assuming lines 6-16 are in a *.cpp file and not *.h; there will be lots of other problems if you put that code in a *.h file).
>>And is there a keyword to explicitly specify to make any function not-inlined?
No. The default is not inlined. A method is only inlined if you explicitly ask it to be with the inline keyword or by coding it as in your first example. Even then there is no guarantee that the compiler will inline the code, inline keyword is only a HINT to the compiler, not a requirement.
This will work ok because it isn't trying to change a string literal
char s[] = "hello world";
*(s+1) = 'a';
I'm assuming client and server are two separate programs. Two processes can not share the same memory location. How to pass data between client and server will depend on the operating system. Its even more complicated when client and server run on different computers.
How the data is interpreted depends on the operating system. MS-Windows and *nix are opposite -- *nix interprets them left to right and MS-Windows right-to-left. That's termed endianness (see wiki article here)
maybe banned users should not be included in that list
You can not use != or == operator to compare two character arrays, you have to call strcmp() to do that if( strcmp(A.signup.username,A.login.username2) != 0)
You can sort the vector without splitting it. call std::sort to do the sorting. All you have to do is to expand the resource number from 1 to 2 digits, such as "resource1" to "resource01" when you read them from the file. That way std::sort (or any other sort algorithm) will sort the vector correctly.
concatenate the two strings before calling system
string fname;
string pick;
cin>>fname;
cout<<"Do you want to open the file?";
cin>>pick;
if(pick=="yes")
{
string command;
command = "umplayer.exe " + fname;
system(command.c_str());
}
else
cout<<"Thanks for your time;
Nope, cleared cache - still nothing doing. I'm stuck in DW! In all of my browsers! And my smartphone.
Uninstall MS-Windows, reformat the hard drive, then reinstall MS-Windows. That should do it :) (just kidding)
Use your compiler's debugger and single step through the program to find out what the problem is. You can also put print statements around the program so that you can see the value of various variables.
line 65: for (int column = 0; column < 5; column++)
Why 5? why not column or 10? (make those two const ints global so that they can be used throughout the program.
we already told you how to fix that problem. Go back and read previous posts.
>>Using new same error happens :
The code you posted is the same as your original code, so you made no changes at all.
>>.can someone help me going with this coding?
Yes, we can help, but we're not going to write it for you.
Change the packing factor to 1 and the alignment problem will go away. #pragma pack(1)
will not put holes in the structure. The pragma is compiler dependent, some compilers may do it differently.
#pragma pack(1)
// your structure goes here
#pragma pack() // revert to default
but i am just a beginner in C++.. thats why i use it.
Use a modern compiler such as Code::Blocks so that you can learn how to write c++ programs correctly. Would you try to learn how to repair 2011 model automobils by using a 1920 Ford? Of course not! So why use a 1980 compiler to write 2011 programs on 2011 operating systems?
Look at the string you are passing to LoadLibrary(). You are passing it the path but not the name of a library.
>>}while(choice != 'n' || choice != 'N');
You need to use &&, not ||.
call recv() twice, the first time to get just the first 4 bytes (assuming the size of the structure is at the beginning, and then again to get the rest of the structure.
copy the DLL into any of the folders listed in the PATH environment variable and it will work regardless of where the application program is located.
check your computer's file system to see if alleg42.dll exists? If it does, is it in one of the folders listed in the PATH environment variable?
Here is an example of how to create a key. Make sure you read the Remarks section of this link
#include <Windows.h>
#include <iostream>
using std::cout;
int main(int argc, char* argv[])
{
HKEY hKey = 0;
DWORD dwDisposition = 0;
long retval = RegCreateKeyEx(HKEY_CURRENT_USER,"Software\\Ancient Dragon",0,0,REG_OPTION_NON_VOLATILE,
KEY_ALL_ACCESS,0,&hKey,&dwDisposition);
if( retval != ERROR_SUCCESS)
{
char buf[255] = {0};
DWORD dwError = GetLastError();
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM,0,dwError,0,buf,sizeof(buf),0);
cout << buf << '\n';
}
else
{
RegCloseKey(hKey);
cout << dwDisposition << '\n';
}
return 0;
}
@OP
Not really. You can use C. OpenGL has bindings for several languages.
Turbo C++ is a 16 bit compiler, so it can't work with OpenGL. He will just have to do it the hard way with Borland's graphics.h for that compiler.
VC++ does the same thing. Just click the error message and the cursor will be moved to the offending line in the editor.
_T is a macro that converts a quoted string leteral to wide character, such as wchar_t something[] = _T("Hello World");
Never heard of _RT macro, and its not defined in tchar.h, where _T is declared.
Use fflush after your scanf or gets lines.
printf ("Enter the number of student >> "); scanf ("%d", &n); fflush(stdin) ; .......... fgets (name[i], sizeof(name[i]), stdin); fflush(stdin) ; .......... fgets (name[i], sizeof(add[i]), stdin); fflush(stdin) ;
I gave you positive rep for one of your previous posts -- I want it back! fflush() is only intended for output streams, not input streams, also a few compilers have implemented it for input streams. Never suggest using fflush(stdin) because its non-standard and not implemented by most compilers.
I tried using my Galaxy Tab once and found it very difficult to post anything, lots of misspelled words that were difficult if not impossible to correct.
That means he is using a different compiler than you are. Just ignore it. Pelles C has no such option.
You have almost all the code you need to solve the problem. Just add a counter, initialize it to 0, then every time getline() is called increment the counter. That's all there is to it.
you need to build a console project. Most likely your problem is that the program runs correctly but quickly removes the console window when its done and you can not see what happened. Programmers commonly put something at the end of the program to make it stop so that you can see it. Add getchar();
just after line 14 in main()
your program worked correctly for me using vc++ 2010 express. Below is the output I got on the console window. But you need to clear the input keyboard buffer after getchar() to remove the Enter key '\n'.
Please specify the number of the task.
* You can choose on number from set = {1}
* Specify "0" to exit
3
Error(!) = Main menu does not support this command.
Make sure that your task number is from menu set of commands and try again.
Please specify the number of the task.
* You can choose on number from set = {1}
* Specify "0" to exit
Please specify the number of the task.
* You can choose on number from set = {1}
* Specify "0" to exit
Press any key to continue . . .
By the time your done with all that beer you will have to destroy all those lines of shitty code you wrote. That would not make me very happy.
The following link might help you:
http://reydacoco.blogspot.com/2011/10/linking-to-ms-access-data-source-using.html
Not likely, after 3 years
The head node itself appears to be uninitialized, except for the next pointer. Try changing the insert() method so that if head == NULL its set to current instead of allocating another new node.
void BulletList::insert(int posx, int posy)
{
node* current = new node;
(*current).next = NULL;
if(head==NULL)
{
head = current; //Head ska väl egentligen inte fyllas, lös detta med arv?
(*head).next = NULL; //Överväg att head inte kan ha y och x
std::cout<<"Head next har något att peka på\n";
//current = new node;
(*current).x = posx;
(*current).y = posy;
(*current).travled=0;
std::cout<<"Head ska få något att peka på\n";
(*current).next = NULL;
}
else
{
node* previous;
previous = head; //Sista kan max vara den som head.next pekare på om head är fylld
while((*previous).next !=NULL) //Hitta sista elemtnet(det går inte att komma åt det snabbt
previous = (*previous).next;
//current = new node; //Skapar en ny node
(*current).x = posx;
(*current).y = posy;
(*current).travled = 0;
(*current).next = NULL;
(*previous).next = current; //Sista elemnetet pekar på det nya, skulle inte behövas om while(previous != NULL
}
}
Projects can contain multiple *.cpp and *.c files, but only one of those files can contain either main() or WinMain() (depending on whether the project is a console or win32 project). If you are attempting to add multiple files each with their own main() then you are doing it wrong.
In that case, you want to create a blank solution, then add multiple projects to it. Remember, each project creates just one unique executable, library, or DLL. But you can have multiple projects in the same solution. When you want several unrelated programs then I find it just simpler to create separate projects for them. But one solution with multiple projects will work too.
Example of Form1.h (see the red lines for my code)
#pragma once
#include "Form2.h"
namespace MyProject {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
using namespace System::Windows::Forms;
using namespace System::Data;
using namespace System::Drawing;
/// <summary>
/// Summary for Form1
/// </summary>
public ref class Form1 : public System::Windows::Forms::Form
{
public:
Form1(void)
{
InitializeComponent();
//
//TODO: Add the constructor code here
//
}
protected:
/// <summary>
/// Clean up any resources being used.
/// </summary>
~Form1()
{
if (components)
{
delete components;
}
}
private: System::Windows::Forms::Button^ button1;
protected:
Form2^ f2;
private:
/// <summary>
/// Required designer variable.
/// </summary>
System::ComponentModel::Container ^components;
#pragma region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
void InitializeComponent(void)
{
this->button1 = (gcnew System::Windows::Forms::Button());
this->SuspendLayout();
//
// button1
//
this->button1->Location = System::Drawing::Point(101, 119);
this->button1->Name = L"button1";
this->button1->Size = System::Drawing::Size(75, 23);
this->button1->TabIndex = 0;
this->button1->Text = L"button1";
this->button1->UseVisualStyleBackColor = true;
this->button1->Click += gcnew System::EventHandler(this, &Form1::button1_Click);
//
// Form1
//
this->AutoScaleDimensions = System::Drawing::SizeF(8, 16);
this->AutoScaleMode = System::Windows::Forms::AutoScaleMode::Font;
this->ClientSize = System::Drawing::Size(282, 255);
this->Controls->Add(this->button1);
this->Name = L"Form1";
this->Text = L"Form1";
this->ResumeLayout(false);
}
#pragma endregion
private: System::Void button1_Click(System::Object^ sender, System::EventArgs^ e) {
f2 = gcnew Form2;
f2->ShowDialog();
}
};
}
Depends on the operating system. MS-Windows I'd say its vc++ 2010. *nix it would be either g++ or Code::Blocks. For portability between the two operating systems (and I think MAC too) it would have to be Code::Blocks.
One is not better or worse than the other. C is more appropriate in some applications while c++ may be better in others. It all depends on the application to be coded and the hardware on which the program will run.
In the original question, X means multiplication, not some unknown variable (the same as * in C and C++ languages).