Dont know what exactly you want but if you want some tuts on interfacign MySQL and C you can visit some of the links given below:
http://www.tol.it/doc/MySQL/
http://dev.mysql.com/doc/refman/5.0/en/c.html
Hope it helped, bye
Dont know what exactly you want but if you want some tuts on interfacign MySQL and C you can visit some of the links given below:
http://www.tol.it/doc/MySQL/
http://dev.mysql.com/doc/refman/5.0/en/c.html
Hope it helped, bye
Hmm looks like your basics are a bit err.. shaky. You got most of the syntax there wrong. Why not revist the basics by learning something about C++ with good books. Some tuts here
I think maybe u looking for something like this:
#include <iostream>
using namespace std ;
int main (void)
{
const int size = 6 ;
char my_array [size] = {'a', 'b', 'c', 'd', 'e', 'f' } ;
cout << "\nThe value of 6th element is " << my_array [5] ;
cin.get ();
return 0 ;
}
Hope it helped, bye.
What kind of optimization do you want to perform on this code, performance wise or lengthwise ? Please be more specific.
I get the following error on the first line of my array...
" syntax error before `}' token "
My eyes are about to fall out of my skull. Can someone take a look for me, everything seems to be fine, but maybe I'm blind.
Here is the code in question...int bin[26][5]={ {0,0,0,0,0},(0,0,0,0,1},{0,0,0,1,0},{0,0,0,1,1},{0,0,1,0,0},{0,0,1,0,1}, {0,0,1,1,0},{0,0,1,1,1},{0,1,0,0,0},{0,1,0,0,1},{0,1,0,1,0},{0,1,0,1,1}, {0,1,1,0,0},{0,1,1,0,1},{0,1,1,1,0},{0,1,1,1,1},{1,0,0,0,0},{1,0,0,0,1}, {1,0,0,1,0},{1,0,0,1,1},{1,0,1,0,0},{1,0,1,0,1},{1,0,1,1,0},{1,0,1,1,1}, {1,1,0,0,0},{1,1,0,0,1} };
The thing marked in red in a round brace which should be replced by curly braces.
Hope it helped, bye.
Welcome to the forums and btw it is a rule here that you should first post your attempt or your code to get help from someone else. Just demanding the code will not fetch a lot of help.
Still since this is your first post i will let it pass. Maybe you can look here for some example:
http://developer.mimer.com/print_result.tml?typ=1&id=1
http://www.physiol.ox.ac.uk/Computing/Online_Documentation/postgresql/ecpg.html
Hope it helped, bye.
There is actually no need to create an array, the problem can be solved using just two "loops". Dont use the function "clrscr()" since it kills program portability and it is a non standard function. If possible try to move from the age old turbo compiler to the list of new compilers provided in the thread mentioned below.
And as far as the thing that you are a newbie is concerned, if you are in need of tutorials, look at the sticky at the top of the forum named "Starting C", it can help you a lot.
Also here is a sample of how you can do it and i wont tell you how to solve the rest of them, you need to think about them.
#include <stdio.h>
#include <stdlib.h>
int main (void)
{
int i, j ;
for (i = 5; i > 0; --i)
{
for (j = i; j > 0; --j)
{
printf ("%d", i) ;
}
putchar ('\n') ;
}
getchar () ;
return 0 ;
}
Hope it helped, bye.
Maybe you can try out something of this sort and make it more robust and suiting to your own purpose.
using namespace std;
int main()
{
int number=10;
int your_number;
char answer = 'y';
do
{
cout<< "\nguess the number: ";
cin >> your_number;
if(number == your_number)
{
cout<<"\nCongrats!";
cout<<"\nWant to try again? ";
cin >> answer;
}
else if (your_number > number)
{
cout << "\nYour guess is a bit too high " ;
}
else if (your_number < number)
{
cout << "\nYour guess is a bit too low " ;
}
}
while (answer == 'y');
return 0;
}
Hope it helped, bye.
Better than using scanf
which is a pretty complicated function which leaves the input stream dirty try out the alternative functions fgets
along with atoi
to take the input from user. For the function prototypes look here:
http://www.cplusplus.com
And why are you using the age old Turbo Compiler? If you can, try to install a better IDE as well as a compiler.
The list of all the new compilers and free IDE can be found in the sticky at the top of the C++ forum in "Starting C".
Hope it helped, bye.
Though i dont know what exactly blackjack is but i think this is wat u want.
#include <iostream>
using namespace::std;
int main()
{
char cards[13]={'2','3','4','5','6','7','8','9','0','J','Q','K','A'};
char deck [260] ;
for (int i=0; i< 260; i++)
deck[i] = cards [i % 13];
for (int i = 0; i < 260; ++i)
cout << i << " " << deck [i] << endl;
cin.get () ; // use this funciton for making the screen stop
//system("PAUSE"); dont use OS functions
return 0;
}
Sorry if this is not what you were looking for.
If you want someone to help you, it would be really better if you err... made your problem description a bit brief giving us what you have so far gathered about the problem and what have u decided till now.
Try to make a skeleton or the framework for your project writing down only the basic things and then post the problem in which you are stuck on. Maybe then we would be able to help you a bit.
Hope it helped, bye.
If you want a third party library for interfacing between C++ and TCL then maybe you should look here
http://cpptcl.sourceforge.net/
As for your second part of the question you havent as such mentionend what exactly is ICE otherwise i would have definately said something.
Hope it helped, bye.
Maybe the below links will help you to increase your knowledge about these things and complete your project:
http://publib.boulder.ibm.com/infocenter/lnxpcomp/v8v101/index.jsp?topic=/com.ibm.xlcpp8l.doc/language/ref/strct.htm
http://www.velocityreviews.com/forums/t317932-bit-fields-in-a-structure.html
http://publications.gbdirect.co.uk/c_book/chapter6/bitfields.html
http://www.cs.cf.ac.uk/Dave/C/node13.html
Hope it helped, bye.
>>cout<< ((A*)3)->get() << endl;
This is using undefined behavor techniques. 3 isprobably not a valid address for an object of type class A.
Oh yes and i overlooked this particular thing. Thanks for pointing it out Mr. Dragon. Maybe this is one of those quizzies questions where you are asked to predict the output of the code snippet.
Rule:
1. Before using any pointer dont forget to allocate memory to it or to point it to an existing object. Hence when using a pointer better ground it (make it NULL) so that you dont end up using it by mistake.
2. Delete only those pointers for those you have explicitly allocated memory using the "new" stmt. Forgettting to free the memory results in what is known as a memory leak.
Hope it helped, bye.
Some of the tutorials for those interested in the OpenGL API programming using C.
Beginner Opengl tuts
http://www.codecolony.de/opengl.htm
http://www.zeuscmd.com/index.php
http://www.sulaco.co.za/tut.htm
Hope it helped, bye.
please help me understand the folowing code....
class A { int a; public: A() : a ( 0 ) {} int get() { cout << "Hello WOrld " << endl; return 0; } }; int main( int argc, char** argv ) { cout<< ((A*)3)->get() << endl; return 0; }
The thing is that when an object is created, its constructor is called but not when the object pointer is created which is the thing in your case. (please get this verified, havent done C++ in quite a while)
So as a pointer to object is created, you dont specifically allocate any memory, the class variable doesnt exist. So as soon as the function si encountered, the "cout" stmt is executed and prints out the output but when encounters the reutrn a stmt, there is as such no "a" to which the object points to since no memory has been allocated.
In the end, yes since the memory is not allocated for the pointer and neither does it point to any object hence an execption is generated. Returning something which doesnt exist is not a very good thing ;)
And btw your code doesnt technically run as an run time exception is generated, there is a difference you know ;)
Hope it helped, bye.
Maybe this link will help you in formulating the problem statement
http://en.wikipedia.org/wiki/Cluedo
First decide on the kind of depth you want to achieve in your game, how your game is goign to interact with the user, the input received by the game and the output. Then make a rough sketch or an algorithm on how are you going to plan the implementation. If using C++ decide on the classes you think are important to the domain and the kind of variables present in the classes.
Move from most logical solution to the most indepth solution, split the implementation into logical modules. Start with the highest abstraction and then decide on the implemetation details of each chunk or module of the hierarchy. Good design methodology and designing is the key to handling projects and if done wisely then the implementation just reduces to the mechanical process of code writing and testing.
HOpe it helped, bye.
Maybe something likie this is what you are looking for:
#include <iostream>
using namespace std ;
bool checker (int number, int& total)
{
if (number == 0)
{
return false;
}
else
{
if (number%2 == 1)
cout << number << " is odd" << endl;
else
cout << number << " is even" << endl;
total += number;
return true ;
}
}
int main (void)
{
int number_buffer = 0, total = 0 ;
cin >> number_buffer;
while ( checker (number_buffer, total) )
cin >> number_buffer ;
cout << "Total: " << total;
return 0;
}
My output:
1
1 is odd
2
2 is even
3
3 is odd
4
4 is even
5
5 is odd
0
Total: 15
Press ENTER to continue.
Hope it helped, bye.
Maybe something like this is what you are looking for
int main (void)
{
int i, j ;
char num_string[] = "1 234 23 45" ;
char tmp [2] = {'\0', '\0'} ;
int length = strlen (num_string) ;
int* values = (int*) malloc (sizeof (int) * length) ;
for ( i = 0, j = 0; i < length; ++i)
{
if ( isdigit (num_string[i] ) )
{
tmp [0] = num_string [i] ;
values [j++] = atoi (tmp) ;
}
}
printf ("\nThe string: %s", num_string) ;
printf ("\nThe integer array which results is: ") ;
for ( i = 0; i < j; ++i)
printf (" %d ", values[i]) ;
return 0 ;
}
My output is:
The string: 1 234 23 45
The integer array which results is: 1 2 3 4 2 3 4 5
Press ENTER to continue.
Hope it helped , bye.
Maybe you would want to have a look here for some OS related resources. It features the implementation of a bankers algo and some of the other advanced topics overview which should help you in deciding which project to choose.
http://www.bernstein-plus-sons.com/.dowling/CSC080/
Hope it helped, bye.
If you are working with C++ and your application really demands high precision and range why not try out some third party libraries like these:
http://www.nongnu.org/hpalib/
http://www.tc.umn.edu/~ringx004/mapm-main.html
http://cliodhna.cop.uop.edu/~hetrick/c-sources.html
Though these libraries require you to study them before you use them, they are worth the effort.
HOpe it helped, bye.
To achieve a difficult task and make a complete software is not easy as it appears and due to teh complexity it is bound to contain advanced concepts so that the software can be realized. If you have the desire to make a software you have to study hard to make it happen. Just asking for something to happen the easy way just doesnt click right. Before creating anything its better you do a reality check.
If you still feel that you can create a text editor software with the knowledge you possess, then best of luck for your project.
It is not called not writing into the files, as mentioned by me earlier, it is called undefined behaviour when the file stream is kept open.
Undefined behaviour can imply successful write as well as an unsuccessful write, but cant be determined when that happens. Use the funtion int ferror (FILE* file_ptr)
to check whether the file stream is corrupted or not.
HOpe it helped, bye.
Its normally a rule of the thumb to close the file pointer as soon as you are finished with it to avoid the undefined behaviour of the file stream which you have opened. Even if you dont close the file stream, they are automatically closed when your program exits but is regarded as a bad practice and may cause subtle bugs due to the corruption of the open file stream. Hence better close the file stream as soon as you are done wiht it rather than waiting for them to be automatically closed.
And btw file poitner returning valid integer as you say means that the file pointer exists and is pointing to the file currently opened but doesnt necessarily guarantee defined behaviour.
Hope it helped, bye.
I have to use a variable of type double to store and manipulate a value for an amount of years. This means I have to ensure that the data input by the user is an integer. The program will accept a non-integer value, but I want it to continue reprompting the user when a non-integer is entered. I thought I had this solved, but it does not work for some reason. Here is the code:
The first step in solving the problem is to properly understand the problem domain and the prog requirements. IF you just want to accept and manipulate a value for amout of years why not just use unsigned long
instead of going to the trouble of using a floating point variable which always ditches the programmer when it comes to comparing it with some other floating number.
Do a second check on you logic, as suggested by Mr. Andor. It would definately solve your problem. Otherwise if you still want to stick to floating point types then you have to follow the advice given by Mr. Infarction which involves deciding on a tolerance value or the deviation value by which your two floating point numbers can differ.
HOpe it helped, bye.
Please seperate your code into logical functions and modules then point out to us which section or logical part is not working as you expected. Giving out such a huge code as Mr. Andor said will not attract much attention. Try localising the problem and then repost. Localised errors in a logically modular program are easy to find out than finding them from a large chunk of data. And btw dont forget to use the code tags while posting code.
Maybe something like this which will implement a basic AND logic will help you understand the thing better:
int main ()
{
bool first [] = {true, false} ;
bool second [] = {true, false} ;
for (int i = 0; i < 2; ++i) {
for (int j = 0; j < 2; ++j) {
cout << boolalpha << first [i] << " AND " << second [j] << " => " << (first[i] && second [j]) ;
cout << endl ;
}
}
return 0 ;
}
Hope it helped, bye.
A C++ compiler, an IDE and a GUI toolkit like the GTK+ which can be used for creating the user interfaces. This should be the bare minimum to get you started with.
BTW dont expect a source code or any help of that kind from here since we can only answer your queries but cant provide you automated homework help.
Best of luck for your future endeavours, bye.
In regards to the how do 'I delete a line from the file problem',you should know that deleting doesn't actually exist.
Rather, you give the illusion of deletion by:-
1. copying the contents of the original file into memory,
2. change the a variable of that file whilst in memory,
3. erase the original file,
4. then write a new file with the ammendments and then rename the new file with the name of the original one.
Wont this present problems if the file is really large like those real time log files or data files. It would be really better if you read a chunk or a logical structure of data from the original file and keep on writing it to a new file and skip those records which you want to as such delete as you say. After this operation if finished the original file can be overwritten with the new one or deleted.
just my point of view, bye.
Try using an global variable instead of passing one
Yes i completely agree with Mr. Grunt, passing global variables is not the best programming practice around. And to suggest this to someone who has just started programming is not a good thing since they dont know the side effects or bad effects associated with them.
i have the program which i wrote by myself... i juz wanted know whether anybody have good idea abt it...
If possible please post your code so that we can have a good loook at it and then try to help you in any way possible.
I really wish people would stop saying crap like this. It does make a difference whether large or small. It's just wrong. Period.
Err.. typing mistake maybe, what i wanted to say was:
"For small programming exercises it may not make a difference for you"...
and the you here is the one who thinks writing clumsy code doesnt make a difference but surely not me.
And by the way i am a proponent of methodological development and good design.
Hope it cleared away the misunderstanding.
Why not try something else which also supports "mouse" as you wanted:
Here is list of some free compilers and IDE which you may find really good and programmer friendly:
http://www.daniweb.com/techtalkforums/thread50370.html
Hope it helped, bye.
Why not just try to complete the assignment in Turbo C. In the help section of turbo C there is a small tutorial which explains how to setup graphics in Turbo C along with a small example.
And just copy pasting the files wont do the job coz Turbo C is not the same as Borland C++, i hope you get the point.
Maybe you can look here
http://www.daniweb.com/techtalkforums/thread11617.html
and
http://bdn.borland.com/article/16170
Hope it helped, bye.
How about starting with this:
http://www.daniweb.com/techtalkforums/thread50370.html
Hope it helped, bye.
The best data structure to keep track of millions of record (i mean there is no such best but still...) B Trees.
B-Trees are specifically designed for managing indexes on secondary storage such as hard disks, compact discs, and so on, providing efficient insert, delete, and search operations. Like binary search trees, B-Trees contain nodes. Unlike binary search trees, however, the nodes of a
B-Tree contain not one, but multiple, keys, up to some defined maximum—usually determined by the size of a disk block. The keys in a node are stored in sorted order, with an associated child node holding keys that sort lower than it—every nonleaf node containing k keys must have k+1 children.
So if poss you can try to implement a class for B-Trees since they exhibit excellent performance where numerous records are concerned. Most Databases like MySQL also use some kind or variation of B+ Trees.
An implementation for ur reference can be found here:
http://www.cse.mrt.ac.lk/lecnotes/cs5224/Assignment5/Assignment5/index.html
Hope it helped, bye.[IMG]file:///C:/DOCUME%7E1/sos/LOCALS%7E1/Temp/moz-screenshot-1.jpg[/IMG]
[IMG]file:///C:/DOCUME%7E1/sos/LOCALS%7E1/Temp/moz-screenshot.jpg[/IMG]
Hi Guys,
Almost forgot. Is there any C function that I can use to extract valid words form a string or I have to do it using something like strtok() to remove spaces and any special characters. Thanks again.
harry
If you are talking about removing field separators and repacing them with spaces then you can do something like this:
#include <stdio.h>
#include <string.h>
#define LINE_BUF 100
int main()
{
char line[LINE_BUF];
char *sep;
while (fgets(line, LINE_BUF, stdin))
{
sep = line;
while (sep != 0)
{
// search for the given chars and if found store
// its ptr in sep. Then they can be changed using
// dereferencing sep.
sep = strpbrk(line, ";.&:,");
if (sep != 0)
*sep = ' ';
}
fputs(line, stdout);
}
return 0;
}
Hope it helped, bye.
Maybe you are talking about an internet bot. They can be used for both malicious and normal purposes , so what exactly you thinking about :P
Even google uses a Bot known as google bot to extract the detailed information from the website when you search for somthing in google.
And as far as your original question is concerned, Perl i think is best for such things though you can even do it in C or any similar lang.
Some info here.
http://www.answers.com/topic/internet-bot
HOpe it helped, bye.
Yes, i think maybe you are wokring on a 16 bit compiler like Turbo C. Move on to some newcompiler and try your code then. If still error persists post here.
Look for the list of free IDE and compilers here.
http://www.daniweb.com/techtalkforums/thread50370.html
I'm new to these forums,and really new to C++,but here is what i need to know.I made a simple calculator in C++ and i was wondering what i need to be able to keep useing it without opening the program everytime...
// simple calc // Chris Wilson #include <iostream.h> int main() { float first; float second; float oper; float output; cout << "|--------------------|\n"; cout << "|-----Chris_Calc-----|\n"; cout << "|--------------------|\n"; cout << "|---------by:--------|\n"; cout << "|----Chris_Wilson----|\n"; cout << "|--------------------|\n"; cout << "Would you like to:\n"; cout << "1)add\n"; cout << "2)subtract\n"; cout << "3)multiply\n"; cout << "4)divide\n"; cin >> oper; if (oper==1) { cout << "enter a number to add\n"; cin >> first; cout << "enter another number to add\n"; cin >> second; cout << "you get\n"; output = first + second; cout << output <<endl; } if (oper==2) { cout << "enter a number to subtract\n"; cin >> first; cout << "enter another number to subtract\n"; cin >> second; cout << "you get\n"; output = first - second; cout << output <<endl; } if (oper==3) { cout << "enter a number to multiply\n"; cin >> first; cout << "enter another number to multiply\n"; cin >> second; cout << "you get\n"; output = first * second; cout << output <<endl; } if (oper==4) { cout << "enter a number to divide\n"; cin >> first; cout << "enter another number to divide\n"; cin >> second; cout << "you get\n"; output = first / second; if (first > second) cout << output <<endl; …
Yes what Mr. WaltP has said pretty much clarifies the situation. If you still need to know some functions which will help you in achieving your task then:
1. Read the current line in a string "currentLine".
2. Let the contents be eg. <p>Here is my content</p>.
3. Find the occurance of ">" which marks the end of the starting tag, the position of the "<" which marks the start of the ending tag.
4. Extract the data between the indexes found using the above procedure.
You can try out the foll code snippet:
int main (void)
{
int a;
char temp[] = "<p>hello to all</p>" ;
printf ("%s", temp) ;
char* my_string = temp ;
my_string = strpbrk( my_string, ">" ) ;
my_string ++ ;
int index = strcspn (my_string, "<") ;
my_string [index] = '\0' ;
printf ("\n%s", my_string) ;
return 0 ;
}
My output:
<p>hello to all</p>
hello to all
Press ENTER to continue.
Though not a very good representation, i just churned that out in some spare time, it will help you understand the basics.
Hope it helped, bye.
When new pointers are created they point to a random location in memory, more like nowhere. It doesnt have to be necessarily an integer variable. Just keep in mind that you cant rely on the value of uninitialized or the pointers which point nowhere. Any attemp to access the value pointed by these variables will give you a junk value and any attempt to modidy that location which doesnt belong to you will give you a run time error.
So a better programming practice is to ground the pointer variables newly created like this:
int main (void)
{
int* p = NULL ; // ground the pointer var
int val = 10;
p = &val;
// pointer now points to the "value" or has the addr of
// "val" as its value.
return 0;
}
At the end of program execution:
eg.
Content of val = 10
Address of val = aabb0034
Content of p = aabb0034
Addr of p = some_arbitrary_value
Hope it helped, bye.
PS: main
returns an int like mentioned by me above.
Yes just follow Mr. Anonymusius's advice and keep some things in mind:
1. Avoid the use of global variables since its a bad programmign practice.
2. If you dont know pass by reference make the function return the updated total. That looks like a good programmign practice :)
3. Another operator which can be used for conditional checking is the ternary operator ?:
bool isEven = ((a % 2) == 0) ? true : false ;
Hope it helped, bye.
PS: 0 is an even number.
Hey Micko, your program properly compiles and gives the expected output. What problem are you facing ????
My output:
6.8, 11.2
Press ENTER to continue.
Hope it helped,bye.
I think you missed a hint of sarcasm in Lerner's reply. :)
Yeah kind of, these people dont even tell me when they are serious and when they are not. Sudden swings from serious thoughts about how to solve the equation to quoting sarcasm are a bit err... hard to determine.
Anyways like Mr. Rashakil Fol said, the problem stmt is simple or complicated depeding on the feat the original poster is trying to achieve. But assuming that its a college exercise, double root detection wont be necessary i think.
And btw good scarcasm Mr. Lerner, you almost got me there. :mrgreen:
What are u exactly trying to prove Mr. Lerner. First you say there is no straightforward way to do it and ask the OP to use an external library. And when the solution is posted you say that even a ten year old kid could do it ???
The link below includes the configuration of newmat library in depth along with few examples.
http://www.unc.edu/courses/2004fall/psyc/285/001/NM10.htm#gcc
Hope it helped, bye.
Protability can be ensured if you aim for the *nix platform since those open source and GNU supporters ensure that the app runs on each and every Operating system whereas Microsoft doesnt give a damn.
GTK is an opensource Graphic Toolkit and is completely portable, so if you use it, portability should not be an issue. If you have some money to spend then you can aim for the QT toolkit which provides the necessary GUI support and has very good support site with excellent video tuts, but of course it comes for a price. The decision rests in you.
Hope it helped, bye.
Just searching for the code to do something or to complete a project is no substitute for solving the problem by putting in your genuine effort. If you want to solve or make this project why not consider it as a fun exercise and try your own hand at it. If you still have problems, look at the code provided on some sites and try to learn from it. It you still have doubts regarding anything post your question here.
Just copy pasting the code and then completeing the project wont do you any good.
The first step in solving the problem is to identify the problem domain properly. Dig out some information on partial fraction decomposition, try to formulate a basic algorithm (the sequence of steps you would follow in achieving the objective).
To start off with, just post a basic algorithm on achieving the desired task and we will definately guide you through the rest of the process.
Maybe the below link will help you in formulating a basic algorithm,
Hope it helped, bye.
It would really benefit to you if you could read on some introductory material to the C++ programming language or some newbie book like "Sams Teach yourself C++ in 21 days" to get the hang of the subject.
This forum will help you definately if you get stuck in your coding attempt anytime but before that you must know the basics of the language and must have dedicated some time and research on it.
Anyways, welcome to the coding hell.
PS: Long time no see Mr. Dave. Welcome back.