49,757 Topics

Member Avatar for
Member Avatar for mIXpRo

hii, this is my .h ,file : [CODE] /* * sortedlist.h * * Created on: Jan 16, 2011 * Author: saeed hardan */ #ifndef SORTEDLIST_H_ #define SORTEDLIST_H_ #include <iostream> #include <functional> namespace mtm { template< typename T, typename Compare = std::less<T> > class SortedList { private: struct ListNode { ListNode …

Member Avatar for mIXpRo
0
192
Member Avatar for snipermann

Hello I have a problem with reading the coordinates of points which are extracted from (..txt ) file.I have read the file with ifstream but I don't know how to use the information then. Thanks in advance the point are in File as followed : u:1.2000 v:4.5400 u:2.5450 v:6.4500

Member Avatar for jonsca
0
305
Member Avatar for imolorhe

I have a program that accepts multiple lines of strings for a variable and accepts another set of multiple strings for the next set of variables, and so on, each seperated by a free line i.e.\n\n How do I write such a program?

Member Avatar for jonsca
0
64
Member Avatar for frogboy77

[CODE]bool is_prime(int a) { if(a==1){return false;} if(a<4){return true;} if(a%2==0){return false;} if(a<9){return true;} if(a%3==0){return false;} int i; for(i=5;(i*i)<=a;i+=6) { if(a%i==0){return false;} if(a%(i+2)==0){return false;} } return true; } [/CODE] critique welcome.

Member Avatar for frogboy77
0
117
Member Avatar for Mr_PoP

main.cpp [CODE] #include "includes.h" #include "LOGMSGs.h" int main() { LOGMSG("TEST"); getch(); return 0; } [/CODE] MYSQLcon.cpp [CODE] #include "LOGMSGs.h" int Mysql() { MYSQL *con, mysql; mysql_init(&mysql); const char * host="localhost"; const char * user="test"; const char * pass="test"; const char * db="NewServer"; con = mysql_real_connect(&mysql,host,user,pass,db,NULL,NULL,NULL); if (con == NULL) { …

Member Avatar for Mr_PoP
0
109
Member Avatar for akifateef

i am a student and i use turbo c 3.0 and 4.5 its compulsory for the computer programming course but there is one error i get when try to run a code having graphics.h on 4.5 that BGI graphics not supported under windows but the same code runs fine on …

Member Avatar for Ancient Dragon
0
103
Member Avatar for Aequitas1

Good evening. I've recently had an assignment to create a doubly linked list that is self contained. This means that the entire list is contained in a single class - the class acts as both the list and the node. I've completed everything and have gotten to my final task …

Member Avatar for Aequitas1
0
4K
Member Avatar for Mr_PoP

logmsg.h [CODE] void LOGMSG(string logmsg,...)//... { stringstream name; name<<"test "<<TM.years()<<"-"<<TM.month()<<"-"<<TM.day()<<".log"; ofstream log; log.open(name.str(), ios::out | ios::app); log <<TM.hour()<<":"<<TM.mint()<<":"<<TM.sec()<<" Message: "<< logmsg<<endl; } [/CODE] main.cpp [CODE] int main() { int a = 100; LOGMSG("type test!!",a,"times"); }[/CODE] but it's only wtite into the file "type test!!" while i want it to type …

Member Avatar for Mr_PoP
0
108
Member Avatar for rcmango

I'm quite new to the standard template library, I'm trying to understand how to use them with my code. There may still be some logic errors in my code. However I am trying to sort out my syntax errors. One big one is this: type/value mismatch at argument 1 in …

Member Avatar for rcmango
0
525
Member Avatar for Violet_82

Hi there, it's been awhile :$ I have just completed a small easy exercise which was to create an Account class, providing a constructor to receive the initial account balance, add some money to the initial balance and withdraw some money (providing that the amount of money to withdraw is …

Member Avatar for Violet_82
0
167
Member Avatar for Frederick2

Hello Vivayan! Its taken me this long to understand your sophisticated program you gave me using STL (Standard Template Library) iterators, container classes, algorithms, and the works! I’m truly grateful for the time you took to develop this program for me, and it inspired me so much I’ve decided to …

Member Avatar for Frederick2
0
175
Member Avatar for MasterGberry

I have been doing a lot of reading online about memory stream types, and I am trying to avoid using the gcnew MemoryStream() from the System header in this program. Here is an example of what I need to be able to use it for. [CODE]var reader = new BinaryReader(new …

0
62
Member Avatar for HeartBalloon

[QUOTE]You said the function returns just a single character yet you are trying to return a character array. You can't have it both ways. What you should have done is [icode]char* getEmpName()const[/icode] -- notice there is a * after char to indicate it will return an array of characters.[/QUOTE] Hi, …

Member Avatar for HeartBalloon
0
378
Member Avatar for MasterGberry

I am having a mental block with this LINQ expression and cannot seem to figure out how I need to convert it to C++. [CODE](var item in inTables.SelectMany(table => table.Items))[/CODE] This code applies to the following piece of code [CODE] foreach (var item in inTables.SelectMany(table => table.Items)) { Trace.Assert(oldDrs.Position == …

Member Avatar for MasterGberry
0
353
Member Avatar for bensewards

Hey guys, This is only my second thread on DaniWeb and I am a beginner programmer. My code looks like this: (really easy to understand and shouldn't need any further explanation besides the fact that I need help understanding why when i give an answer related to the 'else' loop, …

Member Avatar for Fbody
0
584
Member Avatar for Frederick2

I don’t know why my operator += and operator + string class member functions are taking so long to do their job and are so inefficient compared to the Standard C++ Library String Class. Its not that they don’t work; its just that they are slower by a factor of …

Member Avatar for Frederick2
0
575
Member Avatar for sudhirs18

Hi, The program below takes input from user the marks of 10 students in 6 subjects and gives output as: [output] Maths Phy Chem Bio C.Sc Eng Tot Stud_Avg studentname1 10 20 30 40 50 60 210 35 studentname2 20 30 40 50 60 70 270 45 -- -- studentname10 …

Member Avatar for sudhirs18
0
159
Member Avatar for meensatwork

I tried many codes in internet for this but it says Access violation. Can somebody provide me the code snippets in C++ and C# for this?

Member Avatar for ddanbe
0
243
Member Avatar for lochnessmonster

beth = ted; // beth equal to ted ( 1776 ) beth = *ted; // beth equal to value pointed by ted ( 25 ) [B]beth = &ted; // is this statement result in a compiler error? if beth is an int variable[/B]

Member Avatar for ravenous
0
113
Member Avatar for pseudorandom21

Hi, I am in need of a good reference for C++/CLI. Right now I need to know how to exit the main loop of a form, such as if the user clicked the 'X' at the top right. Nevermind, the function Close() is what I needed.

Member Avatar for jonsca
0
302
Member Avatar for insanely_sane

Ok.. so uptil now I've been using the DOS compiler and IDE for C++, version 3.0 by borland...(which is like ancient history).. But now I think it's about time to upgrade :P So since I have been away from C++ for a loooooong time, I need to start from scratch. …

Member Avatar for mike_2000_17
0
192
Member Avatar for GeekInTraining

I have a program which needs to take the logical drives returned from the GetLogicalDriveString function and store them in a string array for later use in a filepath. I tried doing this directly and it failed. Here's my code: [CODE]#include "stdafx.h" #include <iostream> #include <io.h> #include <time.h> #include <string> …

Member Avatar for MosaicFuneral
0
441
Member Avatar for MasterGberry

Ok, so there is a place where the code is being converted into ASCII standard, and then being converted back I believe. I think I know how to do it, but I wanted to get help to make sure that when i am testing for bugs later that this isn't …

Member Avatar for MasterGberry
0
188
Member Avatar for caut_baia

Hello everybody.Say i have a template declaration of a class: [code] template <DWORD Style=BS_DEFPUSHBUTTON, LPSTR Type="button"> class WndObj { WndObj (); }; [/code] Now in the cpp file the definition should look something like this: [code] template <DWORD,LPSTR>WndObj<>::WndObj () {} //so i can go ahead and typedef WndObj<> Button; [/code] …

Member Avatar for mike_2000_17
0
106
Member Avatar for thekitoper

My c++ program asks for input of a integer type if the user inputs a character/string then the program crashes is there another method for this or another way to fix it thank you.

Member Avatar for pseudorandom21
0
339
Member Avatar for XerX

[CODE]#include <cstdlib> #include <iostream> #include "ccc_time.h" using namespace std; int main(int argc, char *argv[]) { double r[10]; Time now; int seed=now.seconds_from(Time(0,0,0)); srand(seed); for (int i=1; i<=10; i++) { r[i]=(rand()%10+1); cout << r[i] << endl; } system("PAUSE"); return EXIT_SUCCESS; } [/CODE] This generates numbers between 1 and 10. What do I …

Member Avatar for MosaicFuneral
0
3K
Member Avatar for MasterGberry

I know that arrays have to be given a size when using them, so I tried to, but this piece of code doesn't seem to want to be accepted by the compiler. data is a std::vector<char> so i tried using the .size() function to use the size of the vector …

Member Avatar for MasterGberry
0
124
Member Avatar for XerX

In a statistics book there is an algorithm of generating pseudo-random numbers with uniform distribution [0,1]. It says: I. Enter an initial variable X positive integer. II. Multiply X by variable "a", which should be at least 5 digits long. III. Divide a*X by value p (positive integer). IV. Take …

Member Avatar for mrnutty
0
4K
Member Avatar for PhysicsExpert

[CODE]Table table; table.UpdateSeats(false, false, false, false, false, false); std::list<bool>::iterator Test = table.GetSeats(); std::cout << "The current status of seats: "; for (int i = 0; i < 6; ++i) { std::cout << " " << *Test; ++Test; std::cout << std::endl; }[/CODE] No compiler errors or warnings, just a Debug Assertion …

Member Avatar for PhysicsExpert
0
802
Member Avatar for SpecialForce

I have the following code: [CODE] #include "stdafx.h" #include <windows.h> #include <GdiPlus.h> #pragma comment( lib, "gdiplus" ) int GetEncoderClsid(const WCHAR* format, CLSID* pClsid); void gdiscreen(); void gdiscreen() { using namespace Gdiplus; GdiplusStartupInput gdiplusStartupInput; ULONG_PTR gdiplusToken; GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL); { HDC scrdc, memdc; HBITMAP membit; scrdc = ::GetDC(0); int Height = …

Member Avatar for SpecialForce
0
653

The End.