456 Posted Topics

Member Avatar for keegansch

And then ... perhaps next step ... 'revise code to crash proof input' ... i.e. to accept only valid user input: # takeInHousePrices.py # def takeInInt( msg, low, high ): while 1: try: val = int( input( msg ) ) if val == 0 or low*1000 <= val <= high*1000: …

Member Avatar for David W
0
369
Member Avatar for sami9356

> We can create an array of objects for any class , irrespective of *whether it has a default constructor or not* Is the above really true? Please see ... http://en.wikipedia.org/wiki/Default_constructor and note the following example that needs to have a defined default ctor /* If some constructors are defined, …

Member Avatar for tapananand
0
710
Member Avatar for Ploutarchos

You could make a copy of the series of numbers, then sort the copies, and then compare the sorted series to see if the same.

Member Avatar for Ploutarchos
0
2K
Member Avatar for yaldoo

Why not use C++ string since you are using C++ ... and something like below ... ifstream fin( fnameCppStr.c_str() ); if( fin ) { int numWords = 0, numChars = 0; string word; // input each word until end of file ... // while( fin >> word ) { ++numWords; …

Member Avatar for yaldoo
0
4K
Member Avatar for maxmiller712

* Do you know how to read a (.txt) file in C? * You could use an extra large array of C strings (Or use dynamic memory ... and a dynamic array, a Cvec) ( see: http://developers-heaven.net/forum/index.php/topic,2580.0.html )

Member Avatar for Ancient Dragon
0
351
Member Avatar for piikun

Do you have examples of output for input of 1 and 2? (Or is the first valid input 3?)

Member Avatar for David W
0
149
Member Avatar for jchelpneeded

> any suggestions on how to replace the specific character with a different character within the string while running a loop? I am in a no prereq class and am not really connecting with this... Hint was: > loop, test character code, if one that needs replacing replace it... Further …

Member Avatar for David W
0
165
Member Avatar for frankie198

You might also like to see this Python 3... example: (that uses a function to loop until valid integer input) (and that loops to ask user if more numbers to be input) (and that demo's the use of a list 'generator') (and that demo's the use of 'join') # sumNumbers.py …

Member Avatar for David W
0
451
Member Avatar for pheonixkid

100+100 -100-100 -(100)+(-100) sqrt(100) The last line above could be tested / handled by: if "sqrt(" then if int then if ")" then process ... The next to last line could be tested / handled by: else if "+(" or "-(" then if int then if ")" then if valid_binary_op …

Member Avatar for L7Sqr
0
377
Member Avatar for ChrisP-C++

> The computer will select a secret number with five different (unique) digits. The object of the game is to guess that secret number. Each guess is answered by the number of digits in the guess number that match or occur in the secret number. You will also be told …

Member Avatar for ChrisP-C++
0
510
Member Avatar for Jean-Luc

You could loop until all input was exhasted putting each next element into the next spot in the array on each loop and yes ... you can also dynamically allocate memory for your array ... and expand the array if it needs more memory You might like to see an …

Member Avatar for Akash_Soni
0
340
Member Avatar for RALTzzz

This may get you started ... // function to return true if char c // passed in is a vowel ... // otherwise to return false bool isVowel( char c ) { c = toupper(c); if( c == A' || c == 'E' || c == 'I' || c =='O' …

Member Avatar for Avishek_1
0
317
Member Avatar for Youssef Mahran

@Avishek_1 NOT good to use gets ... NOR to revert to old style C++ and mix up OP using stdio.h when OP was using C++ <iostream> Also since OP using C++, best to use C++ string. So ... would recommend something like this instead: #include <iostream> #include <sstream> // re. …

Member Avatar for Youssef Mahran
0
123
Member Avatar for nahashon

Recursion can be tricky ... especially when you first try it ... so look up lots of examples where recursion is used. For a popular example, see 'quick sort' The following (inefficent design) on a related example may give you some ideas on how to get started ... /* getLastCharRecursive.c …

Member Avatar for David W
0
177
Member Avatar for Ankitha Nayana

One big thing that is very practical: Collecting and Analyzing Data Note that 'Process Control' depends on the above.

Member Avatar for David W
0
120
Member Avatar for Prince.Questiorina

Since you are using C++, you can use an array of C++ string to hold your words. This may help get you started ... const int MAX_NUM_WORDS = 1000; // make big enough // ... // int main() string words[MAX_NUM_WORDS]; istream fin( "nameOfYourFileOfWords.txt" ); int n = 0; if( fin …

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

Why are you using ... "ArrayStack.h" It would seem much better to use the C++ STL stack (or list) to hold each char ... then we can 'talk' ... Also ... a test program ... and your results with your input vs what you expect to get.

Member Avatar for mike_2000_17
0
684
Member Avatar for Praveen_10

Show us the code you have so far ... are where you think you are stuck. Here is a student beginner level example of using functions to validate user input ... // getValidInt.cpp // http://developers-heaven.net/forum/index.php/topic,46.0.html #include <iostream> using namespace std; int getValidInt( const char prompt[] ) { for( ; ; …

Member Avatar for Praveen_10
0
189
Member Avatar for newbiewwcode

'const' ... in your examples ... tells the compiler that the values in the array are NOT to be changed ... and the compiler will warn you then, if you / your program ... later ... tries to change any values in the array ... Try compiling some code, that …

Member Avatar for newbiewwcode
1
209
Member Avatar for inspire_all

@naveen1993 Please note: 1. old post (now dead? - maybe you missed the date?) 2. NOT portable code ... if one uses <conio.h> , clrscr, getch, etc... 3. maybe you missed the CLEAR warning of @Ancient Dragon about NOT using gets!!! Please Google ... "C why DO NOT use gets" …

Member Avatar for rory.starkweather.7
0
387
Member Avatar for catastrophe2

Since using C++, why not use C++ string and gain the ease of its use ? Try something like this: #include <iostream> #include <string> using namespace std; void my_swap( char& a, char& b ) { char tmp = a; a = b; b = tmp; } // passed in string …

Member Avatar for catastrophe2
0
335
Member Avatar for Brittany_1

In case you have not yet encountered using the C++ STL vector container, (which is really just an easily re-usable and easily expandable dynamic array), you might like to see this demo ... that just uses an array with the max size pre-fixed at compile time ... Note the little …

Member Avatar for David W
0
148
Member Avatar for parth2911

@naveen1993 please see my comments after your post at: http://www.daniweb.com/software-development/c/threads/469587/problem-in-accepting-string-via-gets-function-in-c

Member Avatar for David W
-2
107
Member Avatar for SerenityG

You may like to try this C 'readLine' emulation of C++ 'getline' ... /* CppToC_via_readLine.h.c */ /* using readLine to emulate C++ getline ... */ #include "readLine.h" /* get copy of file: "readLine.h" at this next link ... */ /* http://developers-heaven.net/forum/index.php/topic,2580.msg2864.html#msg2864 */ char encode( char plaintext ) { if( isupper(plaintext) …

Member Avatar for David W
0
234
Member Avatar for Prashant_4

If you write a small program to loop through all the char's a..z and A..Z and take the difference of each matching pair ... the results may give you a 'heads up' on what you may be seeking ? for( int c = 'a', c2 = 'A'; c <= 'z'; …

Member Avatar for naveen1993
0
238
Member Avatar for mcsreerag

Some times the very beginning steps of computer programming seem 'very hard' ... but like learning any new complex thing ... once you 'see' how it works ... and 'how to make it work' ... you are well on your way :) The tricky part (at first with using scanf …

Member Avatar for naveen1993
0
162
Member Avatar for johans22

Your questions are not really clear ... If you need different sized arrays ... you could use dynamic allocation of memory or just use two defines #define SIZE_10 10 #define SIZE_20 20 // etc re. the 2nd question ... you can use if( condition1IsTrue ) { /* */; ) else …

Member Avatar for David W
0
222
Member Avatar for klevis.shkembi

What do you already know about a 4th power poly... ? Can you (differentiate and) find the max (extreme points -> if the graph of y = ax^4 + bx^3 + cx^2 +dx + e opens down) ... or min ... if it opens up ? From the extreme points …

Member Avatar for David W
0
124
Member Avatar for JOHN-shirley

Recalling the above good insights of @Ancient Dragon ... > I would do it by using an array of 255 ints, each element in the array represents one of the characters in standard ascii character set. So, if you enter 'A', then all you have to do is increment array['A']++. …

Member Avatar for David W
0
232
Member Avatar for dennis.ritchie
Member Avatar for endri_1

Just looked your problem over ... This may get you started ... //5 courses available //only 8 allowed in each course //(so ... in main ... need 5 queue, each of size 8) // perhaps an array of StudAryQue // StudAryQue mySchool[5]; // holds all ... // or ... // …

Member Avatar for David W
0
332
Member Avatar for 111100/11000

You have several compile errors ... In line 81: > ISO C++ forbids variable length array 'boardWithPieces' You could use a ... vector < string > vecStr( size ); // calls constructor // if you really need an 'array of strings' You also have redundant and several C (not C++ …

Member Avatar for 111100/11000
0
1K
Member Avatar for vahidgholami820
Member Avatar for rubberman
0
523
Member Avatar for michelemalta
Member Avatar for alagez

Python lends itself to jumping right in and start coding... This example code below may give you some ideas about how to get started ... # selectRobot.py # # 2014-03-26 # ''' The output will be like below: what type of robot application you like choose? a) assembly b) spot …

Member Avatar for alagez
0
278
Member Avatar for Xheis

Or ... start bottom up ... and code in small steps ... making sure that it 'works' as expected, (gives exact desired output), at each step ... and that YOU UNDERSTAND EACH step! There is no shortage of example code ... re. matrix multiplication ... on the web ... if …

Member Avatar for David W
0
316
Member Avatar for trade19

You could try something like this ... (that uses the code given you by @Gribouillis ... slightly revised ... and with comments added that may help explain it for you.) filename = 'myData.txt' ''' 07 13 14 23 45 - 04 13 27 34 41 47 - 49 22 24 …

Member Avatar for trade19
0
410
Member Avatar for Praveen_10

> Because maybe he need to show example of goto statement, I don't care about reasons. Problem is solved and that's all I care about. @Kristian_2 You do know that there is much more to coding, than ... > Problem is solved and that's all I care about. Program (logic) …

Member Avatar for David W
0
379
Member Avatar for Bendez Thyna
Member Avatar for Bendez Thyna
0
218
Member Avatar for soundarya_1
Member Avatar for cxzei
0
148
Member Avatar for catastrophe2

You may like to look here ... [insert sort linked list](http://developers-heaven.net/forum/index.php/topic,310.0.html)

Member Avatar for catastrophe2
0
1K
Member Avatar for Mohammed_9

Sometimes ... the obvious ... is alarmingly simple ... when you 'see' it :) C arrays start at index 0, so next in, from front, has index 1, and ... the last index is size-1 (if size > 0 ), so next to last index is size-2 (if size > …

Member Avatar for Mohammed_9
0
180
Member Avatar for foshan
Member Avatar for foshan
0
199
Member Avatar for soundarya_1
Member Avatar for David W
0
133
Member Avatar for NEMO_1990_2007

Hey ... start a new thread please ... did you not see that one was 5 years OLD ? int main() // not void main in standard C { // your code ... return 0; // main returns an int in standard C }

Member Avatar for David W
0
558
Member Avatar for utsav.srivastava.56

You need to show the code you have so far ... and where you are stuck.

Member Avatar for David W
0
66
Member Avatar for printf.me
Member Avatar for David W
0
99
Member Avatar for <iostream>

Since you are using C++, why not use C++ string (not C string) And don't use (risky) gets ... (even in C) In C++ with C++ string `#include <string>` then can code string cppStr; cin >> cppStr'; // or ... getline( cin, cppStr ); Also ! it is ... int …

Member Avatar for David W
0
154
Member Avatar for danielki

Perhaps your design spec's... really does want you to copy each user input to a file (append to a file) ... right away after each line has been input? The example 'dialog', you provided, does 'lend itself' to that simple interpretation ... yes/no ? If that is what was 'expected', …

Member Avatar for David W
0
549
Member Avatar for TrustyTony

The End.