456 Posted Topics

Member Avatar for Mayukh_1

You may like to see this link re. a way to handle new data types in C ... http://developers-heaven.net/forum/index.php/topic,2598.0.html

Member Avatar for David W
0
139
Member Avatar for Rafiii

You could try something like this: // split_demo.cpp // /* i need to parse the input into two categories: user age and user name. for example, the user input -->> [23:Frank] [15:Jack] [45:] [33:sofia] [] in this case i have more than one argument (delimiter, total of 3 ) which …

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

Your problem can be more easily handled if it's broken up into two BIG steps... 1st step: Using the C++ library linked list, you can code and test out the code for the data processing... 2nd step: You could then code/test a linked list ... and sub in that linked …

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

If you can handle more ... and if your spec's are to compile with a C++ compiler, (but to restrict the 'io' to C style), then ... this example ... may give you some more ideas to get you started with a working shell. // entreEtudiant.cpp // /* The presumption …

Member Avatar for David W
0
256
Member Avatar for ashhad kamal

Note: There are many way to design a solution ... Here is just one simple way ... and a shell program that should get you started: // cal_shell.cpp // #include <iostream> using namespace std; // your functions go here ...?? double add( double a, double b ) { return a …

Member Avatar for NathanOliver
0
224
Member Avatar for ann123

This may give you some more ideas ... and some more tools (C utility functions) to use in your code: (You could use a 'Clist' by including file Clist.h available at ... http://developers-heaven.net/forum/index.php/topic,2582.0.html if your prefer) /* 52Cards.c */ #include "readLine.h" /* re. myAssert */ #include <time.h> const char kinds[] …

Member Avatar for sandeepjkl
0
149
Member Avatar for Curious Gorge

It is possible to create some 'tools' (functions) in C that emulate things available in C++ and Python ... Isn't Python coded in C? You might like to try out some things in this mini library of C utilities ... ... function that are in the following files: readLine.h readWord.h …

Member Avatar for Frederick2
0
468
Member Avatar for ahmediqbal

If you mean that you want the program to prompt for a variable name, you would also want to prompt for the variable type. You could use a C++ map to hold the (unique) name and a pointer to the (new) memory (allocated) to hold that type (and type name).

Member Avatar for ahmediqbal
0
171
Member Avatar for preslav_milev

You will find that help comes more readily if you present the problem clearly. Provide the shortest amount of code possible to illustrate the problem. State clearly the problem ... i.e. do NOT just say: 'there is a problem' / 'something is not working' !

Member Avatar for preslav_milev
0
1K
Member Avatar for Farhan_8

Your data-record structure is NOT what you need here ... Try something like this: // bloodGroups.cpp // #include <iostream> #include <string> #include <cstring> // re. strcpy #include <cstdio> // re. FILE const char* FNAME = "users.bin"; const int MAX_NAME_LEN = 39; const int MAX_ADD_LEN = 99; const int MAX_BG_LEN = …

Member Avatar for David W
0
220
Member Avatar for Prabhu_3

Can you write a 'prototype' for the function? (That could get you started?)

Member Avatar for David W
0
93
Member Avatar for lamlomeh

This example also ensures the prgram will NOT crash if bad data was entered: // drawShape.cpp // #include <iostream> /* **when compiling it gave me the right shape and there is another sol whith a diff way but im not getting it and the other sol goes like ... ** …

Member Avatar for David W
0
148
Member Avatar for lamlomeh

The data file example you provided above ... looks defective? > ... Consider a data file named STORES.DAT, which contains inventory information for four shops. Each line in the file contains the inventory of five types of merchandize in each store ... So ... the file has 4 lines. BUT …

Member Avatar for David W
0
233
Member Avatar for markdean1989

@Petcheco, wrt your suggestion ... please note added comments below: cout << "Enter your string:"; getline(cin, myString); // this will read the whole line cout<<"Enter your name: "; getline(cin, myName); // this will read the whole line // cin.sync(); // SO this is *NOT needed* here // /* cout<<"Age: "; …

Member Avatar for David W
0
2K
Member Avatar for nicky nelson

> We are not allowed to use strlen function. . :/ So ... can you code your own (safe) version of a 'strlen' function? size_t mySafeStrLen( const char* strIn ) { size_t len = 0; if( strIn ) { const char* p = strIn; // rest of your code goes …

Member Avatar for David W
0
196
Member Avatar for liyanaddsce

It would help if you would completely re - design your code ... You are best to use the standard C++ containers ... like vector, list, stack, etc ... rather than messing around with your 'nodes', etc... Also, build your code in steps, fixing each step as you go, and …

Member Avatar for Moschops
0
273
Member Avatar for Asira18

@Syed Ammar please read the previous posts in this thread, especially the patient explanations by ... @Schol-R-LEA & @deceptikon

Member Avatar for David W
0
372
Member Avatar for Mayukh_1

This new little library of C functions, that eases the reading and parsing of a line of text in C (or 'words' of text) may make your problem mush easier to handle ... http://developers-heaven.net/forum/index.php/topic,2582.msg3142.html#msg3142 It permits using C dynamic strings, almost as easily, as one can use C++ strings with …

Member Avatar for David W
0
200
Member Avatar for Clearner123

I found this a short time ago and thought it looked interesting enough to test it out... (I only tested it on a MS Windows OS.) /* cpu_times.h */ /* found at: http://stackoverflow.com/questions/17432502/how-can-i-measure-cpu-time-and-wall-clock-time-on-both-linux-windows */ #ifndef FoundOnWeb_CPU_TIMES_H #define FoundOnWeb_CPU_TIMES_H /* Windows */ #ifdef _WIN32 #include <Windows.h> double get_wall_time() { LARGE_INTEGER time, …

Member Avatar for Mayukh_1
0
330
Member Avatar for sam_7

I think you are forgetting you are coding in C++ ? You may wish to try something like this ... // addNodesIthPosition.cpp // // 2015-05-11 // #include <iostream> typedef int MyType; struct Node { MyType data; Node* next; // default ctor... Node() : data(MyType()), next(0) {} // ctor's Node( const …

Member Avatar for David W
0
183
Member Avatar for kiail

I suspect that you are over complicating things ? Take a look at this simplification: // outPutToBeFixed.cpp // #include <iostream> #include <iomanip> #include <vector> #include <string> const char* MENU = "Welcome to the DVD Collection Program! \n" "What do you want to do?\n\n" "1. Add DVD\n" "2. Remove DVD\n" "3. …

Member Avatar for David W
0
344
Member Avatar for collin_ola

This may give you a start? const string s = "abcd"; const string n = "1234"; for( size_t i = 0; i < s.size(); ++ i ) { cout << s[i] << n[i]; }

Member Avatar for deceptikon
0
304
Member Avatar for Erica_2

It is often a good idea to start with a simple (simpler) version ... Get that working and then upgrade from there. This simpler version may get you started and give you some file read / write ideas to facilitate your progress in your coding problem ... // dataWriteRead.cpp // …

Member Avatar for David W
0
266
Member Avatar for Thomas_25

@tinstaafl, I aways appreciate your insights, and was wondering about the syntax of using ... 'auto' in C++ 11 with the 'map' container ... (and in the context of the OP, I was pleasently surprised to see that C++ 11 'knows' the size of arrays.) This is the syntax that …

Member Avatar for tinstaafl
0
721
Member Avatar for A. Gregory

I almost never (code in a) return 0; at the end of main ... *IN a C++ program* Wheres as, *IN C* ... one *ALWAYS* needs to return an int value in main, and to code that in explicitly, if the compiler conforms to any standard from C89/C90 forward ... …

Member Avatar for David W
0
181
Member Avatar for Ma Nicole Ydralyn

Do you know what a struct (a data record) is ? Do you know how to use arrays? One nice way to handle this might be to create a const array of pairs of (product, price) ... Maybe something like this: #include <string> // ... struct Item { string name; …

Member Avatar for David W
0
6K
Member Avatar for basitji

@basitji, If you wish help on your C++ programming problem, you need to firstly show us the code that you have tried so far ... and any compiler errors.

Member Avatar for Lutina
0
122
Member Avatar for Habib_7

You may also like to see this: (that attempts to salvage your 'get_word' function ... and then to add some extras) /* get_word.c */ #define MAX_LEN_STR "255" #define MAX_LEN 255 #define NUM_WORDS 3 #include <stdio.h> #include <string.h> #include <stdlib.h> #ifndef dwMYASSERT #define dwMYASSERT void myAssert( int condition, const char* msg …

Member Avatar for David W
0
334
Member Avatar for Syed Ammar

Firstly ... please note that it is a bad idea to use #include <conio.h> // and later ... // getch(); if you wish to have portable code that conforms to standard C++ Maybe, by "hard-coding" you were thinking of this ? Consider: struct Student { int id; string name; }; …

Member Avatar for Moschops
0
233
Member Avatar for kearradcrs

@ShiftLeft, I think the OP stated ... > average; // ... display in decimal thus there is a problem with what you suggested, and also ... int Grades [4], Average, Total; // you meant to have Total = 0; // here // for (int count=0; count < 4; count++) { …

Member Avatar for David W
0
195
Member Avatar for Hassaan_2

Can you write a 'shell' program that compiles and runs ok ... producing the exact output expected? What might you put in a start-up working 'shell'? #include <iostream> const int MAX_SIZE_HERE = 10; // keep small at start to keep testing easy // int main() { // print some opening …

Member Avatar for David W
0
425
Member Avatar for turntomyleft

You might like to see this for beginners in Python ... http://developers-heaven.net/forum/index.php/topic,46.msg89.html#msg89 You will find that Python code is also very compact ... A good (and it is also free online) tutorial/text is called 'Think Python' http://en.wikibooks.org/wiki/Think_Python

Member Avatar for vegaseat
0
784
Member Avatar for hadisur_rahman

//Hint: //Do you know what modular arithmetic (here, division) means? //If you have these next two integers stored in 'a' and 'b': int a = 23; int b = 10; // Do you know what values the following x, y would hold? int x = a / b ; int …

Member Avatar for rubberman
-1
241
Member Avatar for Erica_2

You may fine this little edit/clean_up of your code ... a useful example for your future coding problems ... Note: little typos in your code will cause your code to NOT compile. For example: >for (moneky = 0, monkey ... What is the typo above? // monkey_food.cpp // #include <iostream> …

Member Avatar for Erica_2
0
589
Member Avatar for HōñËy
Re: C++

You could try something like this ... to get you started: // binFile_structStudent.cpp // // This example allows ONLY UNIQUE student ID's // #include <iostream> #include <fstream> #include <cstring> // re. strcpy #include <climits> // re. INT_MAX, INT_MIN using namespace std; // NOTE! file gets created first time program is …

Member Avatar for David W
0
283
Member Avatar for SUBHENDU_1

Further to the above Posting Pro @ Schol-R-LEA comments ... and since ... the meaning to be helpful @ Aditya_13 ... posted his first code here ... please also note these comments that are also meant to be helpful to, now especially, @ Aditya_13 ... Please take a look at …

Member Avatar for David W
0
179
Member Avatar for ArpitJ.25

Ah ha ... @ArpitJ.25 you have arrived at a wonderful spot to hang out to see all the code examples sailing past you ... Now ... if you try out the easy examples ... see if you can make some changes and fixes ... Note all the compiler error messages …

Member Avatar for David W
0
136
Member Avatar for Dankwah Emma

Can you show us the code you have so far? in a loop : step 1 input a number after a prompt was printed step 2 check if number was in valid range 1..100 if not after printing error message continue back from loop top step 3 get computer to …

Member Avatar for Rik30
0
126
Member Avatar for sunshine102030

You have NOT supplied enough info about your problem. Using some functions would help to see each of the problem steps. Also ... using some global constants could help here ... maybe for something like the following: if total_kms >= STEP3_RATE_KMS use_rate = STEP3_RATE; else if total_kms >= STEP2_RATE_KMS use_rate …

Member Avatar for David W
-1
202
Member Avatar for Syed Ammar

This thread should help some ... to get started ... https://www.daniweb.com/software-development/cpp/threads/494420/finding-total-occurrences-of-any-word-in-strings

Member Avatar for David W
0
149
Member Avatar for VengefulToast

Maybe you are thinking of a hash table... a kind that also uses lists ??? http://en.wikipedia.org/wiki/Hash_table#Separate_chaining_with_other_structures >Chained hash tables with linked lists are popular because they require only basic data structures with simple algorithms, and can use simple hash functions that are unsuitable for other methods.

Member Avatar for David W
0
183
Member Avatar for Rebeka

Can you show us what code you have tried so far ... so that we can see where you need help? Can you write out the steps you might do on paper? 1st step ... enter amount of water used in each month (in a loop so can do calculation …

Member Avatar for David W
0
140
Member Avatar for AQ

See if you can make the changes suggested above ... then try it out and re-submit the new version for help ... if you need more help? I would suggest also some more descriptive variable names ... names that help you see what is happening as the program flows ... …

Member Avatar for David W
0
323
Member Avatar for Syed Ammar

You could use something like this: struct WeekData { int weekNum; int values[7][2]; // ctor... WeekData( int weekNum, int new_values[7][2] ) : weekNum( weekNum ) { for( int i = 0; i < 7; ++ i ) { values[i][0] = new_values[i][0]; values[i][1] = new_values[i][1]; } } double get_avg() const { …

Member Avatar for David W
0
247
Member Avatar for heyhey123

What have you tried? It would help if you would show us an example of the (file) data (structure) that you seem to need to read and process,

Member Avatar for David W
-1
143
Member Avatar for Sana_5

Please post the code you have tried already, the part that is causing you a problem ... and a copy paste of the compiler error message, if any. Also, the specs for the program, (or a brief description of what the program is supposed to do), so we can easily …

Member Avatar for Schol-R-LEA
0
410
Member Avatar for FraidaL

If one apple costs 65 cents, how much will n apples cost? Do you know how to multiply n*65 for all (positive integer) values of n?

Member Avatar for David W
0
139
Member Avatar for akane.mikazuki

You could use a 'Table Look Up' method ... > I need help to display on the screen rock when user picks rock, paper when user picks paper, and scissors when user picks scissors. Thanks // define table ... const char* CHOICES[] = { "ROCK", "PAPER", "SCISSORS" }; // function …

Member Avatar for Schol-R-LEA
0
486
Member Avatar for ChrisP-C++

I have found Orwell Dev-C++ to work well for C++11 and before ... it is easy for students to use ... can easily compile a single (student type problem) file (withOUT needing to make a project) ... and run to see the output ... without having to add code to …

Member Avatar for mike_2000_17
0
367
Member Avatar for klewis32

You need to clarify your original problem ... 1. Are you wanting, to instead, sort the array in descending order? Or... 2. having sorted the array in ascending order, do you THEN want to move the element at index 0, to the memory location at index size-1, having moved all …

Member Avatar for David W
0
14K

The End.