456 Posted Topics

Member Avatar for mary.fatulalohr

This may be what you were looking for ? #include <iostream> using namespace std; int const ROWS = 2; int const COLS = 3; void print( int a[][ROWS][COLS], int numTables ); void print( int a[ROWS][COLS] ); int main() { int ary3d[][ROWS][COLS] = { { {1,2,3}, {4,5,6} }, { {7,8,9}, {0,1,2} …

Member Avatar for David W
0
162
Member Avatar for neyoibarra

I think what you are looking for is 'error handling' for input of 'invalid data' ... so that your running program will NOT then crash ... when the user enters invalid data. You may like to see this (simple student) example of getting valid integer input from the user: [Click …

Member Avatar for David W
0
130
Member Avatar for neha.jebin.18

This related example may help ... may give you some ideas ? // classStack.cpp // #define MAX_ITEMS 50 template < typename T > class Stack { public: Stack(); bool isEmpty() const; bool isFull() const; void push( const T& ); void pop(); T top() const; T topPop(); int size() const; void …

Member Avatar for David W
0
267
Member Avatar for radhakrishnan.akshai.3
Member Avatar for john.kane.100483

Ok ... you still need to clean it up a lot ... I only edited enough so that I could compile it with an up to date C++ compiler ... and run it so it would not crash ... Fixed up formatting a bit ... too ... so that you …

Member Avatar for David W
0
203
Member Avatar for David W

In the last few days, I have noticed a very old thread ... resurrected ... about a non-standard C getline function. To all who may like a C readLine function ... a C function that reads in a dynamic C string of any length ... a function with a similar …

0
214
Member Avatar for Rashmi_1

If your input data is close to what you show above ... something like the following could do ... /* sortAlphaNum.cpp */ /* 2020-02-24 */ /* Here is what I have to do: To have numbers sorted properly even when they aren't justified with leading 0's: 1 2 ... 9 …

Member Avatar for Rashmi_1
0
907
Member Avatar for chipo

You may have other errors ... best to post the whole section (or program). /* char year= "YYYY"; char month="MM"; char day= "DD"; */ /* But ... I suspect you want to have: */ const char* year= "YYYY"; const char* month="MM"; const char* day= "DD";

Member Avatar for David W
0
160
Member Avatar for john.kane.100483
Member Avatar for shweta_1

[see](http://www.daniweb.com/software-development/cpp/threads/474369/how-to-make-program-of-this-question)

Member Avatar for David W
0
77
Member Avatar for shweta_1

[link](http://www.daniweb.com/software-development/cpp/threads/474369/how-to-make-program-of-this-question)

Member Avatar for David W
0
66
Member Avatar for shweta_1

http://www.daniweb.com/software-development/cpp/threads/474369/how-to-make-program-of-this-question[Click Here](http://www.daniweb.com/software-development/cpp/threads/474369/how-to-make-program-of-this-question)

Member Avatar for David W
0
66
Member Avatar for shweta_1

Do you know how to use Google ... or some other search site ... to do a search? That is a 'basic tool' to master ... in learning computer programming ... these days. Then ... trying out your own code ... and fixing it up to get it working the …

Member Avatar for David W
0
239
Member Avatar for shweta_1

When I just did a Google Search, on *[pure virtual function](http://www.learncpp.com/cpp-tutorial/126-pure-virtual-functions-abstract-base-classes-and-interface-classes/)* right now, this was at the top: (You can do that too ... Yes ?) >When we add a pure virtual function to our class, we are effectively saying, “it is up to the derived classes to implement this …

Member Avatar for David W
0
110
Member Avatar for Dani

Hope 'your new web site' bristols with bright business. Are you thinking of franchises yet ... like one near Toronto Ontario Canada area :) Best regards, David W Zavitz P.S. I noticed your student programming (C/C++, etc.) help site ... some years ago ... but it was only last summer …

Member Avatar for Dani
3
310
Member Avatar for xNeverx

You are also using a C getchar() call with no C/C++ header <cstdio> to match. But since ... coding in C++ ... use cin.get() instead.

Member Avatar for ddanbe
0
177
Member Avatar for glao
Member Avatar for furalise

A quick *Google* turned up this ... (for starters) http://www.cprogramming.com/tutorial/function-pointers.html > ... > Callback Functions > Another use for function pointers is setting up "listener" or "callback" functions that are invoked when a particular event happens. The function is called, and this notifies your code that something of interest has …

Member Avatar for furalise
0
780
Member Avatar for naila.ghafoor.5
Re: opp

A common student 'overload' ... is, overloading operator << to output the data in a (student) data set ... See the following: Data file: myData.txt 1 20000101 Jane Doe 4 19711203 Hannah Mariam Johnston 2 19900303 Joe 3 19990324 James Harry Robinson Program: // simpleVecStructFromFile.cpp // 2013-03-23 // #include <iostream> …

Member Avatar for David W
0
136
Member Avatar for murnesty

To the OP: Have you thought about doing some assembly coding? HLA (High Level Assembly by Randy Hyde) is a great way to start to get a feel for what is going on under the hood ... and it 'leverages' your C/C++ coding skills to let you get to a …

Member Avatar for David W
0
232
Member Avatar for hafza.sana

Perhaps the OP means ... 'under what star' was that DOB ? If so ... then the programmer needs a program that has a table of 'Stars' and dates (or date ranges) ... The program can loop to ask the user to input a (VALID) date of birth ... then …

Member Avatar for David W
0
153
Member Avatar for Jason_9

Further to the above by *Ancient Dragon* ... you may like to recall that C strings are pointers to ... (a '\0' terminated block of) char ... (i.e. addresses) So ... do you wish to ask ... if the addresses are the same? Probably not ... most of the time …

Member Avatar for David W
0
267
Member Avatar for glao

Since you are coding ALL in C, why not start fresh in the C forum ... I think I have some ideas that you may find useful.

Member Avatar for glao
0
330
Member Avatar for mixelplik

This parsing could be a breeze if you use C++ string and stringstream to parse ... using : istringstream iss( cppStrToParse ); // construct iss getline( iss, cppStrMth, '/' ); // to get month and then getline( iss, cppStrDay, '/' ); // to get day and then getline( iss, cppStrYr …

Member Avatar for David W
0
212
Member Avatar for ashley.vanhoesen.7

Just noticed this post, that seems to go with your other post ... Again, it would seem best to use the C++ STL stack (or list) to hold the char's This could serve as a 'quick/cheap' test program ... (and your eval... section, could be vastly cleaned-up/simpified.) // testPalindrome.cpp // …

Member Avatar for David W
0
695
Member Avatar for cnsk90

A first step to coding a solution to any problem is a clear understanding (and statement) of the problem. What is the expected input (validate input to make sure ok.) What is the desired output (is the program to loop for more input, if invalid ... or to loop again.) …

Member Avatar for David W
0
780
Member Avatar for glao

Is what you are trying to do is to transform a vector? i.e. M1*v1 => v2 i.e. Matrix1 times vector1 = vector2 ?

Member Avatar for glao
0
2K
Member Avatar for tharindu123

> give me coding for search and edit a file in c++ Can you supply an example of the types of files you wish to search ... and the types of editing that you wish to do? Also, please show the code that you have coded so far, to do …

Member Avatar for Elixir42
0
523
Member Avatar for leonardo.hieu

I think "Schol-R-LEA" meant to type: using namespace std; // :) It it always good, (especially for beginner coders), to start out with a working shell C++ program like 'Hello World' ... that compiles and gives the exact expected output ... Then ... add a few lines ... (or a …

Member Avatar for David W
0
144
Member Avatar for محمد_44

Can you show us what code you have tried? Start with a working C++ shell ... and add from there, in steps. Show us where you are having trouble(s) ...

Member Avatar for David W
0
132
Member Avatar for churchill.omorere

To get you started ... pseudocode/comments could look something like the following ... #include <stdio.h> int main() { // declare variables // input with prompt to user, the lower starting value // input ... , the upper ending value // input ... , the 'step' value // using a for …

Member Avatar for BobS0327
-1
172
Member Avatar for jalferez1

There are numerous problems with your code. 1. Do not use conio.h if you want portable code. 2. Avoid the dangerous use of gets ... use fgets instead. 3. ... ... This sample code below may help you get started ... It is good to develope in steps, making sure …

Member Avatar for jalferez1
0
219
Member Avatar for blazemadej

So ... are you saying that you need to keep asking for more cents to be input in a loop ... until the user indicates that they are done ? And each time, show the dollar and the cents totals so far? Since you do not wish to use pass …

Member Avatar for David W
0
4K
Member Avatar for john.kane.100483

> Conversion from any base to base 10 Is that what your example tries to do? No! You may glean some ideas there ... though? If you are to code it in C++ ... best to start to do that. Get a working shell that takes (some) input and gives …

Member Avatar for David W
0
250
Member Avatar for kalyan_1

Here is a demo of sorting an array of struct (the array holds a 'Contact list'.) typedef struct Contacts { char name[16]; int area; int phone; } Contacts; Here is the program: /* C qsort examples ... NOTE: needs a C compiler with qsort and const var's demos ... qsort …

Member Avatar for David W
0
131
Member Avatar for jainasamiento

Where is your 'int main()' function ? Every C or C++ program needs one. #include <iostream> // use < > brackets using namespace std; int main() { // your code goes here ... double monthly_sales, commission; bool more = true; do // main loop where you input & output ... …

Member Avatar for David W
0
267
Member Avatar for john.kane.100483
Member Avatar for kalyan_1

If you remember that pointer variables hold addresses, you will be well on your way. Just remember to 'dereference' that pointer, when you wish access the value at 'that address' !!! Pointers are an example of the use of indirect addressing. int x = 10; int* p_x = &x; // …

Member Avatar for David W
0
131
Member Avatar for vibhu mishra

This modified code example may help you to see what is being done as the program executes ... /* permutationsOfString.c */ /* 2014-02-25 */ /* I have an example, coded in C, for printing all permutation of string. I have a problem in understanding, how recursion works in a for …

Member Avatar for David W
0
449
Member Avatar for Ezekiel_1

string spc( 3, ' ' ); cout << '*' << spc << '*'; Is short code ... But ... what is a 'word' ? Does it need to be a real word that is in the English dictionary? If so ... that is NOT what you are doing. See this …

Member Avatar for David W
0
527
Member Avatar for Podouskislender

if each line in the file is exactly numberA someBinaryOp number B then the problem is a breeze //example file: 23.2 + -11.7 -11 * -77.9 128.99 / -11 23.91 - 123.99

Member Avatar for Podouskislender
0
205
Member Avatar for devourer17

If you were to use stringstream objects, your file conversion from .. 7 regular data 'words' on each line ... to ... all 7 sequential words on their own sequential line, (with the exception that the 2nd and 3rd words are both on the 2nd line, separated by one space) …

Member Avatar for devourer17
-1
151
Member Avatar for David W

Because things, these days, seem a little 'slow' around this forum, please forebare this old post, (that was recently resurrected by an inquiring mind), and humour this 'update', in good faith that this update might be appreciated by some beginning students of C++ ... :) // beginnerBadCppExampleCodeBeforeFixedUp.cpp // 2013-08-14 // …

Member Avatar for deceptikon
0
468
Member Avatar for Rahul47

Well ... best to avoid C code style and also avoid pointers in C++ unless REALLY needed ... (C++ has pass by reference) //#include<stdio.h> // #include <cstdio> // but use <iostream> // #include<conio.h> // don't use to have portable code // #include<iostream.h> // use as belowe ... #include <iostream> #include …

Member Avatar for Rahul47
0
368
Member Avatar for sireiz

Great post Jason ! In C++ when you call: fout << value << std::endl; the C++ compiler 'knows' what type of object 'value' is and will output what '<<' is supposed to do for that C++ type of object ... (if '<<' is defined for that object) Note: you can …

Member Avatar for David W
0
219
Member Avatar for charles.dupree.37

Also, a few pretty basic coding suggestions ... int main() { //cin.clear() ; // clears the buffer// <- NO ... it clears cin (error) flags that were set on some cin input // // ... //system("PAUSE") ; // Not portable code // cout << "\nPress 'Enter' to continue/exit ... " …

Member Avatar for David W
0
657
Member Avatar for sash_kp

If you don't know about dynamic memory or function pointers ... you can just do this modification of the above ... /* partition_C_ary.c */ #include <stdio.h> /* my partion 'truth function' used here ... */ int isEven( int a ) { return a % 2 == 0; } void partition( …

Member Avatar for David W
0
444
Member Avatar for ddm

There were actually several problems with the code ... please see added comments, fixes and ... small test program ... // test_DoublyLinkedList.h.cpp // #ifndef DoublyLinkedList_H #define DoublyLinkedList_H #include <iostream> #include <cassert> //Definition of the node template < class Type > struct NodeType { Type info; NodeType < Type >* next; …

Member Avatar for David W
0
584
Member Avatar for avinash.jay.7

1. If you know the range of values in the integer matrix 'm', say the values range form 10 to 1009 then you could create an array to hold the counts for each value // initial all values to 0 int freq[1000] = {0}; //then you could run though the …

Member Avatar for David W
0
2K
Member Avatar for jandanielsaclolo

You said you were learning C++ ... but did you realize that your code was in the C style? In C++, one can pass by reference ... and so will not have to dereference a value passed into a function using the * dereference operator (that is used with passed …

Member Avatar for jandanielsaclolo
0
257

The End.