C++/Questions Answered by Expert Zlatko

SubjectDate Asked
How to move a block in c++ graphics.2/10/2012
  Q: Sir. I am working on my project in c++ graphics which is on making a game and I am trying to make ...
  A: I am not sure if you are having trouble with getting keyboard data, or with drawing. I cannot help ...
problem with strcmp function1/26/2012
  Q: I was trying to compare two strings, both char [50] types, using strcmp function. But an error crept ...
  A: There are two issues. In the sendname method, char* Person::sendname() { ptr = clsname; ...
writing a struct with bit fields into a file.1/9/2012
  Q: halo mr. zlatko. this question is simple but it's part of a much larger project. the issue is ...
  A: When writing to files, the smallest data type which can be use is the byte. You cannot write ...
SilverLight for Windows Phone , String to integer12/30/2011
  Q: I am currently working on a project to create a windows phone application on Visual Studio using C++ ...
  A: You could do this with stringstream if your string has many things and you wish to pick them off ...
dynamic bit-fields12/16/2011
  Q: I was wondering if there is such thing as a dynamic bit-field or any other way to implement it? To ...
  A: Well thanks for being patient, I have had a busy week. To answer your question, you would need ...
Programming Language Source Files Business Rules.12/15/2011
  Q: http://en.wikipedia.org/wiki/Source_code There are some queries from my side regarding Programming ...
  A: In Windows, filenames are not case sensitive, so the C# would compile a .CS file. In fact, the two ...
Programming Language Source Files Business Rules.12/15/2011
  Q: http://en.wikipedia.org/wiki/Source_code There are some queries from my side regarding Programming ...
  A: You could use any extension you like for your new language, but if you use a popular extension, you ...
dynamic bit-fields12/12/2011
  Q: I was wondering if there is such thing as a dynamic bit-field or any other way to implement it? To ...
  A: Yes of course it is possible to implement it. It would be built upon the tools I described in this ...
scope12/6/2011
  Q: How are you? Thanks for taking questions. In my *.h file I have this class class LargeFile { int x; ...
  A: To call a method on an object, you need to have created an instance of the object. For example, in ...
scope12/5/2011
  Q: How are you? Thanks for taking questions. In my *.h file I have this class class LargeFile { int x; ...
  A: The mergeFiles function you have written is not part of the LargeFile class. To make it part of the ...
How to compare two 2D array and display the rows that do not match12/3/2011
  Q: This program i am trying to do is to compare two 2D array and display the rows that do not match, ...
  A: Before, you were comparing a 2D array against itself. For that reason you wanted to avoid comparing ...
Threads11/14/2011
  Q: How do I wake up a thread, so that thread 0 can wake up thread 1 because there are not enough 0's. ...
  A: Hey is for horses. You can think of this as a producer/consumer problem. The fact that the total ...
C++11/14/2011
  Q: Please i want to cheack for this code Sorted Doubly Linked List with Insertion and Deletion ...
  A: I hate to bring you bad news, but the code is having some trouble. When you are writing a program in ...
Threads11/11/2011
  Q: How do I wake up a thread, so that thread 0 can wake up thread 1 because there are not enough 0's.
  A: Usually, a thread will be waiting on some resource and will wake up when the resource becomes ...
Help turning psuedo code into c++ code11/10/2011
  Q: Alright I am trying to write a program that will play Dots and Boxes, the common paper and pencil ...
  A: I would not store the grid co-ordinates (letters/numbers) in the grid, nor would I store the '+' ...
Help turning psuedo code into c++ code11/9/2011
  Q: Alright I am trying to write a program that will play Dots and Boxes, the common paper and pencil ...
  A: It’s an interesting problem, and I think you made a good start, but you have to continue refining ...
deitel c++11/4/2011
  Q: im writing a program trying learn c++ and i keep getting the error message, no appropriate ...
  A: In your main program, you have the line Pet myPet; That line is trying to make a Pet but it is not ...
How to display the rows that do not match in a matrix11/3/2011
  Q: The objective of this program is to get the rows that are not the same within a data matrix. To ...
  A: The major error I made was to have j go from i+1. It needs to go from 0. We want to compare the ...
How to display the rows that do not match in a matrix11/1/2011
  Q: The objective of this program is to get the rows that are not the same within a data matrix. To ...
  A: Lets have a look at this function. bool ArrayCompare2(int* first, int* second, int numelements) { ...
Application of C/C++ in game programming10/26/2011
  Q: I am a student of Aeronautical Engineering (3rd year) from Mumbai, India. I have recently started ...
  A: C and C++ are both used for game programming because of high performance. For graphics, both OpenGL ...
c10/23/2011
  Q: sir pragmas in c language can be used to supress warnings of a programme.can you give a programme in ...
  A: Pragmas are a way to give more information to the compiler to make it behave a certain way. ...
Sorting logic10/5/2011
  Q: I have file having numbers written in one column and the size of the file is 1GB.But in my machine ...
  A: In general, the way to do it is to read in your original file in small parts and sort each part. If ...
linked list9/29/2011
  Q: for some reason the data are not linking in the following code. The purpose of the code is to take ...
  A: The problem is in the input code else { p=p->next; p=new node; } The program is moving off ...
Frequency analysis9/28/2011
  Q: .. I've an cryptographic related assignment where I need to code frequency analysis program that ...
  A: I guess you would need to remember the last 2 character sequence which was recorded. If the current ...
Frequency analysis9/27/2011
  Q: .. I've an cryptographic related assignment where I need to code frequency analysis program that ...
  A: I have a suggestion for you to take a different approach if you need only pairs of letters. Use an ...
c++9/22/2011
  Q: i want to ask i have to chose specialization in it can i learn c++ on line is it easy to do it at ...
  A: It is not more difficult to learn C++ at home but it is not always easy either. With the internet ...
Use of a variable in different projects9/22/2011
  Q: I need to solve a certain problem. I have 2 different projects in Visual .net 2003. One will be the ...
  A: Make sure the namespace is in both the dll header file and the dll source file In the header: ...
Use of a variable in different projects9/21/2011
  Q: I need to solve a certain problem. I have 2 different projects in Visual .net 2003. One will be the ...
  A: I think I can help you. In your dll header file you should declare the variable being exported, like ...
c++9/21/2011
  Q: sir last time you gave clarification for abstraction.thank you. now my question is again ...
  A: I would say that the student class is an abstraction of a real living student because it reduces the ...
c++9/18/2011
  Q: sir my doubt is about data abstraction.data abstractio means representing essential features with ...
  A: You are correct about the integer example of data abstraction. When we do not care about how the ...
c++9/14/2011
  Q: sir my question about objects. fruit is a class.mango is object.in c++ class do not have memory. but ...
  A: What you say about class and objects is correct. I could add another analogy. A class is like the ...
C++9/10/2011
  Q: #include<iostream.h> #include<conio.h> void main() { int i,arr[1]; clrscr(); cout<<"enter the ...
  A: There is no array bound checking in C or C++. You have declared an array of one integer and that is ...
Algorithms9/7/2011
  Q: Can you analyze the time complexity of the following programs. 1. s=0 ; i=1; while (s<n) { ...
  A: The first one is quite interesting. If you write out the values of s and i after each iteration of ...
parameterised constructor8/27/2011
  Q: Sir, Yesturday I was reading about parameterised constructors. I read "There are two types of ...
  A: Implicit construction can occur when a constructor needs only one parameter. It might take only one ...
xml and c++8/21/2011
  Q: Is it possible to work with XML file as database and exclude information from it with c++ in .net ...
  A: For XML access, I have used only the Apache Xerces library, but if you are using .NET, I think ...
Arrays8/14/2011
  Q: Sorry Slatko what i am trying to do if to check if the numbers of a row in the matrix formed by ...
  A: Here is the code I think you want. It goes between the call to secondPrintHeading(), and the comment ...
Arrays8/12/2011
  Q: Sorry Slatko what i am trying to do if to check if the numbers of a row in the matrix formed by ...
  A: I think I understand now. Of all the rows displayed in the second matrix, you want to analyze the ...
How to get the correct rows from a second array8/10/2011
  Q: I have been trying to create a simple program on how to obtain certain rows from a matrix of ...
  A: I was a little confused by your question so I may not understand completely what your are trying to ...
Creating a function8/1/2011
  Q: I thought that understanding and create functions that display the rows that are repeated in an ...
  A: You don't need the ArrayCompare3 and ArrayCompare4 functions to get the output you want. If you find ...
Creating a funtion7/31/2011
  Q: one year ago you created this function: bool MyCompare(int* first, int* second, int numelements) ...
  A: I cannot take the credit for creating that MyCompare function. I helped you to debug it, but clearly ...
how to delete a error command line -std=c++0x in the IDE Code Blocks7/19/2011
  Q: Davis with a bonus CD that includes the Code::Blocks development environment, a full-service GNU C++ ...
  A: I don't use code blocks so I don't know about this problem. I can make a few guesses. Perhaps ...
stack is corrupted erroe7/17/2011
  Q: My program is Matrix transpose and i run it in .net with using MPI. but i get following run time ...
  A: The message "stack around a variable is corrupted" usually means that you have written to an array ...
Cryptography Algorithm6/5/2011
  Q: The following is recursive pseudocode: Function expo2(a, n) if n = 1 then return a if n ...
  A: Sorry, I don't have an algorithm for turning a recursive solution to an iterative one. In general, ...
Cryptography Algorithm6/4/2011
  Q: The following is recursive pseudocode: Function expo2(a, n) if n = 1 then return a if n ...
  A: Edit: In the second program, the line while (reached * 2 < n) should read while (reached * 2 <= n) ...
C++5/29/2011
  Q: can u please recommend me another program to use instead of code blocks ? thanks,
  A: Yes, I can recommend either the Visual C++ express edition available for free from Microsoft at ...
C++5/29/2011
  Q: string* addEntry(string *dynomicArray, int &size, string newEntry) first: why did i write * ...
  A: In the line: string *addEntry(string *dynamicArray, int &size, string newEntry) The * before ...
Program design5/3/2011
  Q: Greetings, I'll try to get straight to the point, but first a little background information on my ...
  A: I think you should not hesitate to explore gui programming. I think it is not correct to regard it ...
Program design5/3/2011
  Q: Greetings, I'll try to get straight to the point, but first a little background information on my ...
  A: To take your programming to the next level, I recommend reading about desing patterns. I recommend ...
c++4/29/2011
  Q: i have to Developed the algorithm in c + + which create a dictionary containing publicly 50 thousand ...
  A: Sir. You haven't really told me what you are having trouble with, and you haven't given me very much ...
c++4/28/2011
  Q: i have to Developed the algorithm in c + + which create a dictionary containing publicly 50 thousand ...
  A: You can create a record to hold one word and store the records in a binary tree. You say you have ...
c++4/26/2011
  Q: i have to Developed the algorithm in c + + which create a dictionary containing publicly 50 thousand ...
  A: You will have to give me a little more information. Does your "dictionary" conatain just words, or ...
FIFO queue array implementation4/20/2011
  Q: I have an assignment to modify a code from my text. This is probably painfully simple, but I'm too ...
  A: That's a great question. You have a FIFO queue, meaning that items are always added onto the tail ...
arrays of integers4/16/2011
  Q: In this problem , given an abstract class to support arrays of Integers. All i need to extends two ...
  A: You've made a good start, but you have not told me what part you are having trouble with or what you ...
file handling3/30/2011
  Q: I just want to ask some help with regarding file handling in c++. I am using bloodshed dev and been ...
  A: I took a closer look at your program. Now I see that you are actually storing products and suppliers ...
C++ code for Binomial Coefficient3/30/2011
  Q: #include <iostream> using namespace std; int binomial(int n, int k); //function prototype int ...
  A: There is no "then" in the C "if" statement. It's simply written as if (n<k) { return(0) ; } The ...
file handling3/29/2011
  Q: I just want to ask some help with regarding file handling in c++. I am using bloodshed dev and been ...
  A: Your program is certainly very slick. I have some ideas for you to consider. First, you should ...
file handling3/28/2011
  Q: I just want to ask some help with regarding file handling in c++. I am using bloodshed dev and been ...
  A: Don't be shy to show me your code. In fact, I always give more effort to answering questions when I ...
Expert Opinion3/28/2011
  Q: In my class, I was asked to write a short essay (and get "expert opions from the internet) about ...
  A: I can give you an opinion, which may help you a little in your essay, but you will need other ...
AVL tree3/19/2011
  Q: hye..i'm a beginner in c++.so my knowledge about avl tree coding is almost zero.so can u help me ...
  A: An AVL tree is a tree that keeps itself balanced. That means that for any node, the depth of the ...
Destructor of Singleton class3/19/2011
  Q: Please go through the following code: ...
  A: I think the destroy should also be static because you should not need an actual instance of ...
C++ help3/17/2011
  Q: For my assignment I am to write a program that reads a series of integers from the keyboard. I am ...
  A: You are correct that you need two integers to save the min and max. Declare them like this: int ...
C++ cout stops working3/16/2011
  Q: I wrote a program that seems to compile and work fine, except that after a do-while loop completes, ...
  A: Notice in this loop do { token = strtok(NULL, delimiters_1); cout << token << ...
Writing to a file3/12/2011
  Q: I am trying to convert a code which runs on windows to run on linux. Part of the code takes a string ...
  A: Sam, I don't think this is a Linux issue. If the file does not already exist, then the only way ...
problem in seperating files3/9/2011
  Q: i have done this code and i dint know how to separate this code into two file infix.h and infix.cpp. ...
  A: The general idea is to place all the function declarations into a header file. Create an infix.h ...
need advice3/8/2011
  Q: Sir, c or java-which one should be learned first for a complete biginner. sorry for my english & ...
  A: You do not need to know C++ to take a scja or scjp course. It is not that C++ is the basics and Java ...
need advice3/7/2011
  Q: Sir, c or java-which one should be learned first for a complete biginner. sorry for my english & ...
  A: Either one will teach you the basics of programming, but I would choose Java over C because it is an ...
c++ dictionary implementation2/25/2011
  Q: I have to code a dictionary in c++ which behaves like this: reads a text (from file) ,gives each ...
  A: I don't know what your algorithm is, but I would do it like this. Create a structure to hold your ...
MFC2/23/2011
  Q: My simplest MFC application stopped working telling: C2661: 'new' : no overloaded function takes 1 ...
  A: I cannot reproduce the problem with my Visual Studio 6. I would need to see your entire project to ...
Input\Output files2/22/2011
  Q: I want to read data from a file, store it into an array, and then display it on the screen. After ...
  A: When you read through the entire file, to the end, there is an error bit set to indicate the end of ...
C++ program help2/14/2011
  Q: #include <iostream> #include <fstream> #include <iomanip> #include <cmath> using namespace std; ...
  A: Try changing the type of additionalTime from float to int. You are doing only integer arithmetic ...
C++ errors help2/12/2011
  Q: Here is my code: #include <fstream> #include <iomanip> #include <cmath> using namespace std; int ...
  A: Joe, the structure of your current code is this: main() { while() { } else cout << ...
C++ program help error2/12/2011
  Q: #include <iostream> #include <fstream> #include <iomanip> #include <cmath> using namespace std; ...
  A: Peter, in the line if{15 < Total_minutes <= 30){ change if{ to if( Also, syntax in the line if(15 ...
C++ program help2/10/2011
  Q: #include <iostream> #include <fstream> #include <iomanip> #include <cmath> #include <time.h> ...
  A: Make sure to have #include <assert.h> at the top of your program. You might be interested in the ...
C++ program help2/10/2011
  Q: #include <iostream> #include <fstream> #include <iomanip> #include <cmath> #include <time.h> ...
  A: Edit: -------- Hello Peter. I see you were quick to read my answer. Actually, there is a problem ...
C++ newbie need help with fixing code2/9/2011
  Q: I’m a C++ newbie and I’m taking my 2nd class but, I’m confused as to how to do my homework problem. ...
  A: I felt the best way to help you was to show you by video. Have a look here: http://goo.gl/CXo2l ...
C++ if and else problem2/9/2011
  Q: #include <cmath> #include <iostream> #include <iomanip> #include <string> const double PI = ...
  A: There is a small misunderstanding in the "if" syntax. When you say if(shape=='C'||c) You are ...
game2/1/2011
  Q: greetings! i would like to inquire if my design on my game is correct,i am implementing a user ...
  A: Here is what I think. When the game starts, I suppose it will ask for a user profile to load. By ...
C/C++2/1/2011
  Q: #include <stdio.h> #include <conio.h> int f1(int x) { return x*x; } int f2(int y) { ...
  A: You can check the order by putting in print statements into the functions. With my compiler, the ...
Data Structures and Lists1/30/2011
  Q: I'm trying to grasp the concept, I have to create a shopping list asking a user to provide items, ...
  A: You've made a good start on the assignment. I can see that you understand the ideas of memory ...
Random function in Turbo Borland1/29/2011
  Q: How can I write a random function in a Turbo C++ that will help me in making a gambling game?
  A: Although I do not use turbo C, I believe it uses the standard C library rand function. Here is a ...
Fibonacci Sequence1/27/2011
  Q: I am trying to do a fibonacci sequence (to help me learn). It is to figure out the sum of even ...
  A: The modulus is separate from division. 2000000%2 is not division so it is a misconception to say ...
Fibonacci Sequence1/26/2011
  Q: I am trying to do a fibonacci sequence (to help me learn). It is to figure out the sum of even ...
  A: The % operator is used for modulo division. It returns the remainder from a division operation. Your ...
A computer mystery1/17/2011
  Q: Zlatho Hope you've been doing well. Ever since I've purchased a new wireless Microsoft mouse for ...
  A: I cannot give you a technical explanation about why the problem is occurring, but you seem to have ...
unresolved external symbol error when using template class1/11/2011
  Q: I tried to create a template class. But while building i get the following linker error: 'unresolved ...
  A: I have been working on your code in visual C++ 6.0 and I do see the unresolved references too. There ...
RE: Basketball Bet Program12/3/2010
  Q: This program involves calculating winnings/losses for basketball bets where the betting company ...
  A: It makes things much clearer. I now understand that the Winner bet is a type of betting scheme, and ...
access specifier12/3/2010
  Q: When a sub-class is deriving from a base-class, what does the access specifier imply? eg. I have a ...
  A: In your example, Base::i is not accessible from main because it is not public in Base. The Base::j ...
Basketball Bet Program12/1/2010
  Q: This program involves calculating winnings/losses for basketball bets where the betting company ...
  A: Virtual functions allow you to write code that uses some base class. At run time, you can pass a ...
string str = "hello " "world" "!"12/1/2010
  Q: As you can see on the Subject, do you know why we can use double quote to concatenate the stirngs? ...
  A: I hope I spelled your name right! The concatenation is a language feature handled by the compiler. ...
2D Array Issue11/28/2010
  Q: I am not sure with the 2D array. There are a few errors during compilation. Compiler complains the ...
  A: You can initialize the table array as you are doing if you make it a static variable. I assume that ...
Class Inheritance11/27/2010
  Q: I have 2 classes, Rectangle & Block. I am trying to make than communicate. However there are a few ...
  A: Below is the corrected program. I am not including a text explanation of what I did. I am trying ...
c programming11/17/2010
  Q: Student grading system i've done program for students grading. it require user to input no of ...
  A: You can read my tutorial about console input in C here ...
c programming11/16/2010
  Q: Student grading system i've done program for students grading. it require user to input no of ...
  A: Your code int value_input; valid_input=0 while (valid_input==0){ printf("\nMark Subject %d\t: ...
RE: More help with polynomials11/15/2010
  Q: Remember the program I had to work on last time with polynomials? Now that we've learned about ...
  A: My answers to you are comments in the code so have a look there. There is more work for you to do. ...
c programming11/15/2010
  Q: Student grading system i've done program for students grading. it require user to input no of ...
  A: Yes you have many compiler errors, and some logic errors. When you get a compiler error, you should ...
More help with polynomials11/15/2010
  Q: Remember the program I had to work on last time with polynomials? Now that we've learned about ...
  A: If you want to have a special case for quadratics, you need to program it explicitly. You need a ...
More help with polynomials11/14/2010
  Q: Remember the program I had to work on last time with polynomials? Now that we've learned about ...
  A: Yes the operator overloading is easy. You don't really need to think of any new algorithms, you ...
Ploting points11/11/2010
  Q: I'm new to C++ and I have an assignment where I have to plot the point for f(mx+y)where m=1 thru 25 ...
  A: You can create a C function to calculate your expression like this: /* f() = mx + y */ float ...
Algorithm: Adding Fractions Using 'For' Loop11/8/2010
  Q: I am trying to design (write a program in C++ or pseudo code) for a 'For' loop that will calculate a ...
  A: Edit: Hi Again Thank you for the kind review. Please understand that the back and forth you ...
Algorithm: Adding Fractions Using 'For' Loop11/8/2010
  Q: I am trying to design (write a program in C++ or pseudo code) for a 'For' loop that will calculate a ...
  A: To write pseudo code means to write instructions in a natural language, like English so that the ...
Algorithm: Adding Fractions Using 'For' Loop11/8/2010
  Q: I am trying to design (write a program in C++ or pseudo code) for a 'For' loop that will calculate a ...
  A: Nested loops are not the way to approach this problem. With a nested loop, an inner loop runs ...
C++help11/7/2010
  Q: I am trying to build a 2 dimensional array of random numbers, which I accomplished. I am also ...
  A: I don't know how you got any output from your program, because the version you sent me doesn't ...
need a little help with this program11/1/2010
  Q: Now here's a stock program (see code below), Now, I've made instantiated the buyprice as 69.34 and ...
  A: You've fallen into a common trap. Your Stock class has a float totalcost data member, and your ...
Generating prime numbers10/31/2010
  Q: Hey. I have this assignment in which i've to generate prime numbers up to a certain limit. Since i'm ...
  A: The problem with the program is that it is checking for divisibility, not primeness. You see that ...
Read word from text file.10/29/2010
  Q: Im creating program that will read one word from the text file. The word i want my program to read ...
  A: I could help you more if I knew what the profile.txt looked like and what you needed to do once the ...
RE: need help with polynomials assignment10/28/2010
  Q: Check out my code now, I think the polynomial printing works now. I used all if statements to do ...
  A: Ok, I found 3 errors, and I made a minor change to fix them. The following are errors, because they ...
RE: need help with polynomials assignment10/27/2010
  Q: Check out my code now, I think the polynomial printing works now. I used all if statements to do ...
  A: Mike ! I'm impressed. I really am. It's pretty good but I can make some suggestions. The program is ...
need help with polynomials assignment10/25/2010
  Q: I'm having an assigned, it says to create a class for working with polynomials up to degree4. Five ...
  A: Edit: October 26 Mike, when printing out your polynomial, don't try to do it all in one cout ...
need help with polynomials assignment10/23/2010
  Q: I'm having an assigned, it says to create a class for working with polynomials up to degree4. Five ...
  A: The word "other" is the name i gave to the polynomial being passed into the calcSum method. Here is ...
need help with polynomials assignment10/22/2010
  Q: I'm having an assigned, it says to create a class for working with polynomials up to degree4. Five ...
  A: I think you have the right idea about how to do the assignment. You have a few issues with your ...
Working with functions10/16/2010
  Q: I tried in the following program get the equal rows from a matrix of tens but without any success. ...
  A: The matrix of 10s doesn't really exist. The program just prints out the 10s data based on the ...
sound10/15/2010
  Q: ,,can u pls tell hw to play a wave/mp3 file in c++. i am using turbo c++ ver 3.0.
  A: To play a wav file you can use the windows multimedia API function PlaySound Here is a sample ...
clock10/14/2010
  Q: ,i made this clock program on my own,, i need to know how to exit from this program,,,nd goto to ...
  A: Henry, the clock function never returns because, after these three nested loops are done p: ...
How to hold the right data into an array10/12/2010
  Q: I ran the last program you mailed me and the output is not what I want. Could you run the program I ...
  A: I assume you want the smallest and largest sum of only the rows that have your wishedNumber because ...
How to hold the right data into an array10/8/2010
  Q: With this program I mailed you asking you why the arrays foundSums[rows] and foundRows[57](if I set ...
  A: October 10 Raul, as promised, here is some code that may do what you want. I have commented my ...
How to hold the right data into an array10/7/2010
  Q: in the program I mailed you the size of foundSums[] and foundRows[] I set it to 11 just because in ...
  A: Yes, there are some problems caused by the malloc, but malloc is not the cause of the strange output ...
C++10/7/2010
  Q: write a program for merge sort using divide and conquer technique.
  A: I suggest you read about merge sort at http://en.wikipedia.org/wiki/Merge_sort Then, if you don't ...
C++10/5/2010
  Q: i have to write a program for class that will prompt the user for 10 integers one at a time then ...
  A: I think you must be running an older version of your program, because the current version doesn't ...
C++10/5/2010
  Q: i have to write a program for class that will prompt the user for 10 integers one at a time then ...
  A: That's a good start, but where is the end of the do/while loop ? You will need a counter to count ...
How to hold the right data into an array10/4/2010
  Q: the following program output a matrix data with the sum of each number of a row, later the user ...
  A: If you know the array size at runtime only, then the best option is to allocate memory dynamically. ...
Re: need a little help with function templates10/4/2010
  Q: So now, I have 1. printed out arrays as given in main. 2. sorted the arrays 3. saved the sorted ...
  A: It looks good. You don't need to use the sizeof, but I think its better because as you change ...
Re: need a little help with function templates10/1/2010
  Q: So now, I have 1. printed out arrays as given in main. 2. sorted the arrays 3. saved the sorted ...
  A: If your objective is to read from the file and print, without storing in the array, then you don't ...
Re: need a little help with function templates10/1/2010
  Q: So now, I have 1. printed out arrays as given in main. 2. sorted the arrays 3. saved the sorted ...
  A: Notice that every time the program calls getarray, the file is reopened, because getarray opens and ...
C++ confusion9/30/2010
  Q: So I am new at C++ and here is my code. Everything works except the last part. I need to display ...
  A: I think one of the problems is with the comparison of midtermproject against a letter. The syntax ...
need a little help with function templates9/29/2010
  Q: I'm working on an hw assignment, and I'm asked to write a function template that sorts the given ...
  A: If you want to open the file in the template function, and you want to save the previous contents, ...
need a little help with function templates9/27/2010
  Q: I'm working on an hw assignment, and I'm asked to write a function template that sorts the given ...
  A: Your bubble sort works. The reasons you are getting wrong output is because you are trying to print ...
need a little help with function templates9/27/2010
  Q: I'm working on an hw assignment, and I'm asked to write a function template that sorts the given ...
  A: You declared your template correctly, but the sort algorithm is not correct. You may think it sorts ...
Algorithm9/24/2010
  Q: I am learning programming by myself (let me be honest, with your great help), I asked somebody ...
  A: Sorry for the delay. Sorry also that this explanation is a little long. It will help if you try to ...
Algorithm9/22/2010
  Q: I'm sorry for my explanation but as I said before I was not sure about how to get my idea right. ...
  A: Here is my solution. Sometime you will have to tell me where do you get the ideas for these array ...
Algorithm9/21/2010
  Q: my goal is how to create an algorithm for the following program. I am trying to create a program ...
  A: I think that a single array of integers is not enough information to solve the problem. Your "row" ...
Calculate function Running time9/20/2010
  Q: I have to make efiiciency check for diffrent traversal like preorder,inorder and postorder. I have ...
  A: If you are using the Windows operating system, you can use the two calls to QueryPerformanceCounter ...
C input recognition9/18/2010
  Q: I'd like to know a way in which we can accept a boolean function from the user, and perform ...
  A: Awesome question. The short answer is to use the shunting algorithm. See ...
Just a simple one.9/13/2010
  Q: Well, I am new to experts.com and to C++ programming too. To get straight to the point, I wish to ...
  A: It is debatable whether C++ is more powerful than another programming language. It depends on what ...
How to print results in a table9/9/2010
  Q: I checked when the user enters a size of 1 or 2 and it is working the way I want. The output I ...
  A: Ok, if you say your program is running correctly, I believe you. However I probably broke it because ...
How to print results in a table9/9/2010
  Q: I am sorry for not explain better what the program does. First I want to say the program does what ...
  A: Raul, I think you sent your question to the wrong person, and that person sent it the the question ...
How to print results in a table9/8/2010
  Q: How to print results in a table ...
  A: September 9 ------------ I suppose I can answer some of your questions. It seems that analysis is ...
Opening a dialog box in the upper center of the page.9/8/2010
  Q: I am using Visual C++ 6. Since it is somewhat tall, I would like to have a dialog box open in the ...
  A: I assume you are using MFC. You can position your dialog window using CWnd::SetWindowPlacement in ...
Read/Write to a file simultaneously from different users9/7/2010
  Q: Hey Zlatko, i am writting an application, where many users will try and have access to the same ...
  A: I think there is no problem with using the C++ iostream classes with shared files but the iostream ...
c++ program help9/4/2010
  Q: I was going to start going into c ++ because I thought it was used to make programs like MSword. ...
  A: Sure, use google to search game programming in c++ to find web sites. Use google books to find ...
An array inside a 2D array9/3/2010
  Q: I added some code to the program in topic " An array inside a 2D array ". After the user enter five ...
  A: If you don't need to keep the last row, then you can go back to an array of 5 rows as you had in ...
An array inside a 2D array9/1/2010
  Q: I am learning by myself this amazing programming language C++ and I would like to know the ...
  A: Edit September 2, 2010 Raul, I've created a google site at ...
An array inside a 2D array9/1/2010
  Q: What I want is the set of 5 numbers entered by the user be appended to the beginning of the array ...
  A: You have two options here. One option is to create your 2D array with as many rows as you will need ...
c++ progrming8/29/2010
  Q: I am a college student taking a introduction class to C++ language.i have no idea about the ...
  A: I can help you with your question but I'm not sure how much experience you have with C++. My idea is ...
c++8/27/2010
  Q: will return types of different versions of the functions in case of function overriding? they will ...
  A: OVERLOADING ==================== Overloaded functions with the same parameter list must all have the ...
Problem getting the desire output8/24/2010
  Q: Now my problem is how to get the desire output in a table of numbers. This is the program I have ...
  A: You need to print the correct number of spaces based on how long the text is in a particular cell. ...
help with pow function8/24/2010
  Q: I'm writing a simple mortgage calculation program, here's what I have so far (obviously not ...
  A: A little bit of formatting shows that you are passing only one parameter to pow. You have ...
convert C++ codes to Fortran codes8/23/2010
  Q: Is it possible to convert some C + + codes to FORTRAN codes? Is there any way? sincerely Amir ...
  A: You should use Microsoft Visual Studio (free express edition) in addition to, or instead of, your ...
convert C++ codes to Fortran codes8/23/2010
  Q: Is it possible to convert some C + + codes to FORTRAN codes? Is there any way? sincerely Amir
  A: I do not know of any commercial program that will translate FORTRAN to C, but I've never searched ...
intro to programming8/20/2010
  Q: I tried to write a code for this program but I have no luck to run it. I need you to help me. ...
  A: I would have liked to see your code, even if it didn't run. It would help me to help you learn. ...
c++ programming8/20/2010
  Q: The process of finding the largest number(i.e the maximum of a group of numbers) is used frequently ...
  A: With my previous answer to you, I showed you how to do input from the keyboard into variables. Use ...
How to display a message and numbers not present into a matrix8/13/2010
  Q: What I really want is a display like this: ROWS (0) (1) (2) ...
  A: I think I understand your question now. Step 1) The program asks for a number. Then it returns all ...
How to display a message and numbers not present into a matrix8/9/2010
  Q: What I want from the following program is to get the rows with a desired number in column (0) and ...
  A: I had a little trouble understanding what you want, but I think you want to display if a number is ...
procedure oriented language?8/9/2010
  Q: What is procedure oriented language?
  A: A procedure oriented language is one where an algorithm is broken down into a series of steps that ...
general8/8/2010
  Q: i want to develop some appliction in in c++.can you give me some idea about any such projects .i am ...
  A: The fundamentals of programming can be learned with any computer architecture (8 bit, 16 bit, or ...
c++ graphics8/7/2010
  Q: act i have made simple program in c++ to move a circle left of right by pressing 1 for left and 2 ...
  A: There is a function called kbhit which will return non-zero if there is a character in the keyboard ...
c++8/7/2010
  Q: i want to develop some appliction in in c++.can you give me some idea about any such projects .i am ...
  A: If you want to switch to visual studio, you can get a free visual studio c++ express edition from ...
C++ file input problem7/21/2010
  Q: I am very new to C++, as such I am having difficulties with the settings. I tried for several hours ...
  A: I certainly understand how frustrating computers can be. I suspect that before you moved to the ...
How can i correct an error in this program(to use arrow keys for selection in a menu)..7/19/2010
  Q: I have wrtiten a program to use arrow keys for selection in a menu.. I wrote it as a function so ...
  A: The problem with the program is in the way temp is being passed from main to smenu and from smenu to ...
Using and doing calculations on dates in c++7/16/2010
  Q: Sir, I am a high school student and I am creating a Library Managment Program. I need to use and ...
  A: You can get the local date with another constructor like this: #include <time.h> class Date { ...
Using and doing calculations on dates in c++7/14/2010
  Q: Sir, I am a high school student and I am creating a Library Managment Program. I need to use and ...
  A: I'll help you with your program. Since you are asking this question in the C++ category, I'll assume ...
C++ Code to print the following pattern using While7/12/2010
  Q: Respected Sir, Kindly help me correct the given code to print the pattern using While Loop; * ** *** ...
  A: It is much easier to do this with nested while loops. You should try to take the earlier exercise, ...
void summary wont work7/11/2010
  Q: I was hoping you could look at this and tell me why my void summary is not working I cant figure it ...
  A: It's nice to hear from you again. The problem with the program is that the lowest and highest ...
visual studio 2008 vs Borland C++5.01!7/10/2010
  Q: I'm using Borland C++ 5.01 until now! Now I want to use Microsoft Visual Studio 2008 as compiler. ...
  A: The Borland C++ compiler is quite old and the C++ standard has changed since the Borland compiler ...
C++ Code to print the following pattern7/8/2010
  Q: Respected Sir, Kindly help me complete the given incomplete code to print the pattern- A Ab ABc The ...
  A: That's good work. The code you sent me, with the cout change is this: void main() { int i,j; ...
C++>>Read certain text from a text file7/8/2010
  Q: How can i read a certain range of word from a text file which contain 100+ of lines. eg, i would ...
  A: I don't know why you are getting that error. I cannot get the error. However, instead of using ...
C++>>Read certain text from a text file7/7/2010
  Q: How can i read a certain range of word from a text file which contain 100+ of lines. eg, i would ...
  A: I can show you how to read the lines of the file. I do not know how to get from the input to the ...
C++ Code to print the following pattern7/6/2010
  Q: Respected Sir, Kindly help me complete the given incomplete code to print the pattern- **** *** ** * ...
  A: Nice to hear from you again. In this program you have 2 nested loops. The outer loop controls the ...
C++ Code to print the sum of the first 10 odd natural numbers6/29/2010
  Q: Respected Sir, Kindly help me Complete the following Incomplete Code, #include<iostream.h> ...
  A: I think you need to set sum to 0 before your loop starts and you need to fix the for loop statement. ...
program6/24/2010
  Q: 4 4 3 3 3 3 2 2 2 2 2 2 1 1 1 1 1 ...
  A: If you are having trouble with this assignment, try to do something simpler. When you have success ...
not sure how to do it6/15/2010
  Q: My teacher has given us a program to write involving void functions, I have the program 90% complete ...
  A: Wow! A beautiful program. I think what your teacher wants is for you to move all the problem ...
strnicmp/OnKeyPress6/11/2010
  Q: I'm using Visual Studio 2010 and I have the following C++ code segment: #include<StdAfx.h> ...
  A: I get this question quite often. The simplest way to check for keyboard input without blocking is to ...
a counter program6/11/2010
  Q: I want to have a program that counts the number of vectors like (X1 , X2 , … , Xn) subject to : Sum ...
  A: Nice to hear from you again. So, you want to count the number of vectors whose elements sum to r, ...
strnicmp/OnKeyPress6/10/2010
  Q: I'm using Visual Studio 2010 and I have the following C++ code segment: #include<StdAfx.h> ...
  A: Your first parameter to strnicmp is the variable a which is a character. The function needs a ...
How to compare 1D arrays inside of 2D arrays to check if they are equal.6/6/2010
  Q: I did what told me: bool comparison; for(int i=0; i< rows; i++) { for(int ...
  A: I think the program is working, but the display may not be what you want. Below is the original ...
How to compare 1D arrays inside of 2D arrays to check if they are equal.6/5/2010
  Q: This is a program about to detect whether 2 rows are equal, not whether all of them are equal inside ...
  A: Your MyCompare function has a typing error. You have if(first[i]!=second[i]); <---- notice this ...
lab 4- last one phewwww (argv)6/2/2010
  Q: I have one final lab due by midnight Friday. I did what I could so far with this one. This time just ...
  A: Nice to hear from you again. If I understand correctly, the objective of this last lab is to add ...
size of an array6/1/2010
  Q: Is there any function in C++ that can calculates the summation of some values? I have some ...
  A: Yes, you are correct that the size of an array must be an integer constant, and yes, 'b' is a ...
size of an array5/31/2010
  Q: Is there any function in C++ that can calculates the summation of some values? I have some ...
  A: As far as I know, there is no function to sum the contents of an array. It is a simple matter to ...
Shared Memory5/24/2010
  Q: I would like to learn about shared memory implementaion. I have basic idea about that. But, still i ...
  A: Shared memory is used for communication between processes. I have seen it used in simulations, where ...
Software design (concept)5/24/2010
  Q: I am building this program that gathers stock market data(open, high, low, close, volume). My ...
  A: I don't know if I am helping you or not with this response. First I think you should not try to ...
Software design (concept)5/21/2010
  Q: I am building this program that gathers stock market data(open, high, low, close, volume). My ...
  A: If you are writing your own analysis functions, you can certainly have them each accept a vector of ...
Software design (concept)5/21/2010
  Q: I am building this program that gathers stock market data(open, high, low, close, volume). My ...
  A: I believe that your first approach is more correct. The 5 data elements all refer to a single stock ...
how to set amount of time for user input5/19/2010
  Q: Here is my code I attempted, am trying to set a timer on user input. What I mean is how can I set ...
  A: Once you call a function like getline, you have no control over the program until getline returns. ...
C++ help with a problem-structs this time5/18/2010
  Q: I have done what I can with the info/assignment and now I am stuck. I appreciate your time and ...
  A: I think you make a good start on your program, but some parts were incomplete and did not compile. ...
C# vs Java vs C++5/18/2010
  Q: I am a 21 years old guy. Don’t really know much about programming (especially OOP) and software ...
  A: Very good questions. A GUI library is used to display windows on your screen. GCC is an excellent ...
C# vs Java vs C++5/17/2010
  Q: I am a 21 years old guy. Don’t really know much about programming (especially OOP) and software ...
  A: I don't think there is one correct answer to your question. Any of the 3 programming languages will ...
pointer?5/13/2010
  Q: i have a question to write a program that takes a phone number as input from the user and stores it ...
  A: I don't really understand your assignment. I don't understand Sample 2, and I don't understand how ...
c++5/11/2010
  Q: I changed program . Regards Tina #include <iostream> #include <iomanip> #include <sstream> ...
  A: I had a quick look at the program. I found only 1 serious problem. Try 1999 1 1, and 2000 1 1, you ...
Re:5/7/2010
  Q: You didn't answer that in this program Where and How can I use reference variables? Regards. ...
  A: The general rule is that simple types (like int, float, char, ...) should be passed by value and not ...
Re:5/7/2010
  Q: You didn't answer that in this program Where and How can I use reference variables? Regards.
  A: Sorry that I missed your question. You can use references in many places. When passing parameters to ...
C++ help with a problem5/6/2010
  Q: I went online with the teacher today and went over the code remotely. I am still having issues with ...
  A: I think you will have problems if you try to write the entire program at once and then try to ...
C++ help with a problem5/5/2010
  Q: I would appreciate any help you can provide me to complete this. Thank you so much! Assignment: ...
  A: You have some good ideas in your program. I see that you are trying to split the program into ...
date5/4/2010
  Q: it works very well;) correctdate is a part of the main program.In main program I want to calculate ...
  A: In your days function, you have two instances of iss being declared. You have istringstream ...
date5/4/2010
  Q: I've a program that it doesn't work.Could you help me. It's a part of a program.I want to check two ...
  A: Your program almost works. There are just a couple of problems with it. One problem is that you ...
Adding arrays4/29/2010
  Q: Now I am in the same program trying to add another array (totalwinningNumber), I am not sure if I ...
  A: I think the problem is with for(int j = 0; j < noOfwinningNumber; ++j) ...
Public variables accross source files within a program4/28/2010
  Q: Zlatko. I am building a program that analyzes certain aspects of a file and writes a graph showing ...
  A: There is no strict way to create a global variable in file A, and have it visible to only one other ...
Reading a file4/25/2010
  Q: I am trying to learn c++ by myself , I made this program, it is about to read data and put it into ...
  A: It's great that you are teaching yourself a new skill. I'm glad to help out. The program is not ...
Bank Accounts Program4/23/2010
  Q: I am so overwhelmed, I have no sense of direction. I'm not clear about virtual functions etc. I'm in ...
  A: I understand your frustration. Virtual functions are one of the more confusing parts of C++. Your ...
Destruction of CDC class4/23/2010
  Q: Zlatko. I am working on a VC++6 Graph program that analyses the contents of a file. When the user ...
  A: I'm not really experienced in this part of MFC, but according to the msdn documentation, a release ...
Nested Loops4/22/2010
  Q: I have to write a program. The Question is this: Jody is a teenager who is very fond of sweets. ...
  A: Good work on your program. The logic is correct but problems happen if you input an improper ...
dynamic creation of template class objects4/15/2010
  Q: I need to read a delimited file and then extract fields and other information that i want to store ...
  A: Your project sounds very interesting and I am happy to do what I can to help out. Right now it seems ...
call CPU Time4/14/2010
  Q: What is the command for calling CPU TIME in C++? ANSWER: Amir, the functions on windows are ...
  A: Amir, here is some sample code. #include "Windows.h" typedef unsigned __int64 PC_t; PC_t ...
dynamic creation of template class objects4/14/2010
  Q: I need to read a delimited file and then extract fields and other information that i want to store ...
  A: Your English is fine. It is much better than my Spanish. Early in my career, I spent many months in ...
dynamic creation of template class objects4/12/2010
  Q: I need to read a delimited file and then extract fields and other information that i want to store ...
  A: It would be helpful if you give me with a sample of the delimited input file. Also it would be good ...
Problems adding shift key to left mouse button function4/11/2010
  Q: Zlatko, I'm creating a graph with Visual C++ 6 that both analyzes and changes certain parts of a ...
  A: Sorry for my error, the flags is a bit field, meaning you need to look at individual bits to get the ...
Problems adding shift key to left mouse button function4/11/2010
  Q: Zlatko, I'm creating a graph with Visual C++ 6 that both analyzes and changes certain parts of a ...
  A: The MK_SHIFT in all caps is defined as a macro. That is why you need an alternate case. Are you sure ...
Message Box without .NET4/10/2010
  Q: I need to check what version and is there one of .net framework installed on user's PC. So here is ...
  A: Branko, I usually use CreateProcess to start another program. Below is some sample code I was using ...
Message Box without .NET4/10/2010
  Q: I need to check what version and is there one of .net framework installed on user's PC. So here is ...
  A: It might be simpler to add the dot net checking and installation code into the MFC dialog project. ...
Message Box without .NET4/10/2010
  Q: I need to check what version and is there one of .net framework installed on user's PC. So here is ...
  A: You can create an MFC dialog box project to display a message box without dot net. Visual studio ...
crash while writing or reading from memory4/10/2010
  Q: My program still some times crashes. This time I think I could find the source of problem but I ...
  A: When the function enters, the j0, k0, and h0 are uninitialized. It means they take on unpredictable ...
Programming Issues4/9/2010
  Q: I'm fairly new to programming, really don't understand most of it. I've attempted a program that I'm ...
  A: I'm not sure if you got my last answer. Here is the correct code you should change. NumDays& ...
Programming Issues4/9/2010
  Q: I'm fairly new to programming, really don't understand most of it. I've attempted a program that I'm ...
  A: Sorry for confusing you. I wanted to explain the reasons for everything. Generally for programming, ...
A little more help ??4/8/2010
  Q: okay ..here is my revised code ..It works great.But is there another way to write it aside from ...
  A: The atoi function converts a string of digit characters to an integer. So the string "123" becomes ...
Programming Issues4/8/2010
  Q: I'm fairly new to programming, really don't understand most of it. I've attempted a program that I'm ...
  A: I like your question because it made me think. You did a pretty good job, but there are some things ...
Another question4/4/2010
  Q: I have some problems with my program or my compiler.I use Borland C++ 5.02. Some times when i run my ...
  A: Calling functions causes changes in the program memory. A function call will use the stack (a region ...
Help with a program.please4/4/2010
  Q: Here is my Program.Basically It does everything i want it to do , except check for data errors. I ...
  A: Sorry that I did not make it clear. For restricting row numbers, try this modified version of the ...
problem in running process4/4/2010
  Q: I have some problems with my program or my compiler.I use Borland C++ 5.02. Some times when i run my ...
  A: in chseq_d, the variables j0 and k0 are initialized only when ...
Help with a program.please4/4/2010
  Q: Here is my Program.Basically It does everything i want it to do , except check for data errors. I ...
  A: >Im not following what you mean by using column - 'A' instead of column-65 make the purpose more ...
problem in running process4/3/2010
  Q: I have some problems with my program or my compiler.I use Borland C++ 5.02. Some times when i run my ...
  A: Amir, my build of the program did not crash so I don't know what the problem is. I tried Microsoft ...
Help with a program.please4/3/2010
  Q: Here is my Program.Basically It does everything i want it to do , except check for data errors. I ...
  A: The infinite loop comes with cin >> someInteger when you accidentally enter a character. Input can ...
problem in running process4/1/2010
  Q: I have some problems with my program or my compiler.I use Borland C++ 5.02. Some times when i run my ...
  A: Amir, it is not caused by the goto instruction. It is caused by an error in the program. The program ...
Check Box problem3/30/2010
  Q: I am building a program that analyzes certain aspects of a file and writes a graph showing its ...
  A: I think you are not using the correct array syntax. It's like this: // Declare an array of CButton ...
Integer class3/30/2010
  Q: I am trying to write an integer class that allows the user to enter a number 10 digits long. I am ...
  A: I assume that you are storing the number in your class as an integer, and that you want to return ...
Check Box problem3/30/2010
  Q: I am building a program that analyzes certain aspects of a file and writes a graph showing its ...
  A: The GetDlgItem will return a CWnd* which you can cast to CButton* and store in an array or vector of ...
Dynamic Array????3/29/2010
  Q: I am stuck with a question in my programming book and unsure how to answer thisWrite a program that ...
  A: A dynamic array is an array that grows as elements are added to it or sometimes shrinks as elements ...
C++ Hashing Table in Data Structure3/28/2010
  Q: .Zlatko,, I have some question to ask you regarding my project question. This is the question : ...
  A: I wrote a sample hash program in the hope that it will be useful to you. The hash table uses ...
C++ Hashing Table in Data Structure3/28/2010
  Q: .Zlatko,, I have some question to ask you regarding my project question. This is the question : ...
  A: Before I go on to your new questions, I want to continue with what I started yesterday. I want to ...
C++ program and I am stuck!3/27/2010
  Q: Here is my program. I cannot get it to work ..following that are the instructions..any advice would ...
  A: Well, I think I got the output you want. I had to change many of the setw calls, and left justify ...
C++ Hashing Table in Data Structure3/27/2010
  Q: .Zlatko,, I have some question to ask you regarding my project question. This is the question : ...
  A: I would like some more time to think about some parts of your question but I can give you some ideas ...
C++ program and I am stuck!3/26/2010
  Q: Here is my program. I cannot get it to work ..following that are the instructions..any advice would ...
  A: My advice to you is to first get the program to compile. Start with the first error. Fix it, then ...
write a function that returns an array as result3/22/2010
  Q: How can I write a function that it can return an array as result? because of most of programs that I ...
  A: Sorry, there is no pretty answer to this question. When you allocate memory with new, you get back ...
write a function that returns an array as result3/22/2010
  Q: How can I write a function that it can return an array as result? because of most of programs that I ...
  A: The syntax in main should be like this: int* result; result=myfunction(); There should be no '*' ...
write a function that returns an array as result3/21/2010
  Q: How can I write a function that it can return an array as result? because of most of programs that I ...
  A: There are 2 ways of returning an array from a function. The most common way is to allocate memory ...
Read a value at location in C++3/10/2010
  Q: ! Sir, I am trying to read a particular location's value and want to store it in a variable and use ...
  A: If I understand correctly, your program has a window with a text field in it and the user types ...
c++ help with loops3/7/2010
  Q: Write a C++ program asks the user for some integer number, N. The program will display the first N ...
  A: Juan, You have to read through all of my answer. You cannot just copy my code into your editor. My ...
c++ help with loops3/7/2010
  Q: Write a C++ program asks the user for some integer number, N. The program will display the first N ...
  A: I would say that your outer loop is supposed to run until the desired number of primes has been ...
Question regarding a graph in 'C'.3/6/2010
  Q: I am working on a VC++6 Graph program that analyses the contents of a file. One of the first things ...
  A: Using the filelength function is OK, but I would do it this way: int fd = _open ( “TrackName.trk”, ...
Question regarding a graph in 'C'.3/6/2010
  Q: I am working on a VC++6 Graph program that analyses the contents of a file. One of the first things ...
  A: When declaring arrays in VC 6, you need a constant for the array size. The current C standard allows ...
Need help3/5/2010
  Q: I need to implement an algorithm using c++ data structures. I have got two files file1 and file2. ...
  A: Your mentor may be correct that a map will be too slow for searching 600,000 entries. As you ...
Error in my program3/3/2010
  Q: i got a problem in my assignment.. whenever i insert alphabet or symbol into the answer.. it become ...
  A: Your program works fine as long as the user inputs exactly what is expected. If the user input ...
Need help3/3/2010
  Q: I need to implement an algorithm using c++ data structures. I have got two files file1 and file2. ...
  A: I can help you but I'm not sure about how much help your asking for or how much experience you have ...
circular link list2/23/2010
  Q: I try with this code.. but still cannot make it.. help..me sir..Thanks void List::DisplayList() { ...
  A: That's pretty good, but your num value is one less than it should be because the first node is ...
circular link list2/23/2010
  Q: I try with this code.. but still cannot make it.. help..me sir..Thanks void List::DisplayList() { ...
  A: If you set lastNode to null, you cannot then ask what lastNode->next is because you cannot go ...
need help; circular link list2/22/2010
  Q: Can you help me with this code.. this is actually a single link list..I want to change it to be ...
  A: You have the right idea now. You did a good job, but there are some problems. When index == 0 and ...
need help; circular link list2/22/2010
  Q: Can you help me with this code.. this is actually a single link list..I want to change it to be ...
  A: Think carefully about what a circular linked list is. The head points to the first element, and the ...
add node to the last link list in C++; needs help2/21/2010
  Q: This program actually have 4 function. 1)AddLast = to add a new node at the last of the list ...
  A: Please make sure that your Node constructor sets the Node::next pointer to NULL. You did not supply ...
Queue2/21/2010
  Q: I am writing a queue program which gives priority to female. The program will read infile.txt ...
  A: I recommend you use this loop for your input while (!infile.eof()) { string sex; ...
Analyze a textfile/cpp file2/19/2010
  Q: I am trying to read in test.cpp in the main function for analyzing. But I am not sure how to make ...
  A: Nice to hear from you again. It looks like you are trying to open a file for input, read it in line ...
Please Help2/9/2010
  Q: , I was wondering if you could help me with this... on my laptop there is a VGA port, let's assume ...
  A: As far as I know, this is not possible. The VGA port on your laptop is an output. It does not ...
2D Array2/8/2010
  Q: The outputs are incorrect. I am trying to perform +,-,*,/ for 2D arrays. Can advise me the correct ...
  A: The "this" pointer points to the object whose methods you are running. Each object has a this ...
Pointers, Pointer to Pointers, and New[]2/8/2010
  Q: Hey Zlatko, I ran into a runtime error where I was (apparently) writing out of bounds for my array ...
  A: Here's a handy reference http://www.difranco.net/cop2220/op-prec.htm The problem is that the square ...
copying2/7/2010
  Q: sir how can i copy my value of s1 into anothe string s3 using operator overloading function in the ...
  A: If you want to implement operator+= without strcpy, you have to copy the characters to the end of ...
copying2/7/2010
  Q: sir how can i copy my value of s1 into anothe string s3 using operator overloading function in the ...
  A: That looks good to me. In my system, I had to have: #include <string> and I had to have main ...
copying2/7/2010
  Q: sir how can i copy my value of s1 into anothe string s3 using operator overloading function in the ...
  A: You can use an operator= to do assignment from one string to another. const strng &strng::operator= ...
2D Array2/4/2010
  Q: The outputs are incorrect. I am trying to perform +,-,*,/ for 2D arrays. Can advise me the correct ...
  A: The reason the code is not giving the expected results is that the call to this->operator()(int,int) ...
C++ count down2/4/2010
  Q: 1. I would like to know how to write a C++ program to "count from 10 to-5". 2. The other quest is, ...
  A: Your basic program skeleton is something like this #include <iostream> // for input and output ...
C++ Implicit Conversion...2/2/2010
  Q: What is the problem with implicit conversion constructor?.. Why we need explicit conversion with the ...
  A: Implicit conversion occurs with single parameter constructors. It is easy to accidentally have the ...
Arrays1/31/2010
  Q: I'm having problems with arrays, I know what they are for, but when it comes to implementing it, I'm ...
  A: I think you did a good job on your program. I'll make some suggestions. You should make your ...
Pointer arithmetic1/30/2010
  Q: Using <cstring> header. If I want to compare two char arrays and display whether their elements are ...
  A: Steve, I really like the lookup table idea! But since the two arrays may be of different sizes, I ...
Pointer arithmetic1/30/2010
  Q: Using <cstring> header. If I want to compare two char arrays and display whether their elements are ...
  A: First, I need to comment on your code. You need two character arrays to hold data, and one function ...
Pointers1/27/2010
  Q: I am trying to output ASCII chars from a to z but my function crashed. Pls advise me further. Tks. ...
  A: Your program is crashing because you are trying to put a byte into a location pointed at by 'a', but ...
Pointers1/24/2010
  Q: I am trying to display an array of digits using rand. My final result need to be: 1) Output all ...
  A: I see you are using a recursive algorithm for swapArray. That's very good. Your code had a few small ...
corrections in translation C# to C++1/23/2010
  Q: I have translation by Instant C++(C#edition)Tangible Software from C# to C++ as follows: for (I = ...
  A: I am not so good with formatting output to the screen. In C++, output formatting is done by setting ...
Pointers1/22/2010
  Q: I am trying to display an array of digits using rand. My final result need to be: 1) Output all ...
  A: Steve, that is a good try. You have some confusion about when you need to allocate memory. You do ...
exception 131/19/2010
  Q: while compiling i got an exception 13 error. can u help me fix it. i used turbo c++ on win xp. i'm a ...
  A: I have bad news for you. Your code has many problems. I have removed many of them but there are 24 ...
Binary File1/17/2010
  Q: I need to perform a few tasks: 1. Read the infile.txt 2. Creation of binary file 3. Update binary ...
  A: Steven, I find your question very confusing, but I have tried my best to make sense out of it. I ...
Binary File1/16/2010
  Q: I need to perform a few tasks: 1. Read the infile.txt 2. Creation of binary file 3. Update binary ...
  A: The corrections to you Task 1 are below.See my comments starting with //XXX The problem is that ...
vector as a data member1/13/2010
  Q: This is a very short test program where I want to create objects which contain a vector as a data ...
  A: The problem is that you are using Public with a capital 'P'. It should be lower case. Also, in your ...
fstream... struct... union1/11/2010
  Q: I am doing a program to read a sample infile.txt & ouput to outfile.txt The program is student ...
  A: I like how you did the FileToArray function. Although there is no error checking, you made good use ...
C++ screen position1/11/2010
  Q: I'm using code blocks to write very basic programs for my son to get interested in C++... Q1...all ...
  A: What you are looking for is not a part of the C/C++ language or standard library. You need a Text ...
C++ screen position1/11/2010
  Q: I'm using code blocks to write very basic programs for my son to get interested in C++... Q1...all ...
  A: I assume you are using the Code::Blocks IDE. I don't have any experience with that and I don't know ...
fstream... struct... union1/10/2010
  Q: I am doing a program to read a sample infile.txt & ouput to outfile.txt The program is student ...
  A: Steven. I commend you for doing so much of your assignment before asking for help. I have corrected ...
c++1/9/2010
  Q: write a program in c++ to get the following structure: * * * * * * * * * * * * * * * ...
  A: To solve this puzzle, you should break it down into three pieces or functions. Many times solving a ...
executing a '.exe' file in a cpp program1/7/2010
  Q: i want to run an exe file 'quiz.exe' from a cpp prgram 'game.cpp'. I referred many examples and ...
  A: To run a program from another program in the Windows operating system, you use the CreateProcess ...
Passing values by reference11/24/2009
  Q: My program is almost finished ,but I am confused on how to pass values by reference through ...
  A: When you write a program, you should compile often. Every time you finish a function, or a major ...
Passing values by reference11/24/2009
  Q: My program is almost finished ,but I am confused on how to pass values by reference through ...
  A: Your syntax for passing by reference is correct. You use an ampersand in the function declaration. ...
c++11/24/2009
  Q: i hv done the changes,nt sure is right or wrong.but wen i compile it display nthing.nt sure which ...
  A: Look closely at the code and think about what the program is doing here //-- Read file of words ...
c++11/23/2009
  Q: could u pls help mi.i realli hv no idea on hw to start.i hope u could guide mi on tis program.i will ...
  A: I think the common words are supposed to be ignored, just like numbers and punctuation. So, you need ...
doubt in pointers11/22/2009
  Q: i am basically reading a txt file and making a link list database. i read all the elements in the ...
  A: I will need to see your program before I can help you. I cannot tell what can be wrong from your ...
c++11/22/2009
  Q: could u pls help mi.i realli hv no idea on hw to start.i hope u could guide mi on tis program.i will ...
  A: Your choice of a map for the STL container was excellent. You need to add a function to convert a ...
c++11/19/2009
  Q: ! what is the code in c++ for finding square root of a number without using the function sqrt() in ...
  A: Edit: When I was a student, I learned the Newton's method for finding the roots of an function. The ...
c++11/18/2009
  Q: could u pls help mi.i realli hv no idea on hw to start.i hope u could guide mi on tis program.i will ...
  A: Do you have a sister named Lisa ? I'll help you but I don't have too much time at the moment. What ...
where can i f ind information for my compiler11/17/2009
  Q: please, i am currently using a dev c++ compiler but often times, i have read about statements like ...
  A: I believe that DevC++ is an IDE which uses the MinGW port of the GCC compiler. The gcc web page is ...
Sorting and Searching Array Problem11/16/2009
  Q: My name is Ernest. I am trying to teach myself C++. I am currently working on a C++ problem that I ...
  A: I'm not sure I understand the problem, especially since you did not have processing of student names ...
c++11/15/2009
  Q: could u pls help mi.i realli realli need alot of help frm u.i still cn't seems to do the interest ...
  A: Lisa, you should only display the account if the account's customer ID is the same as the customer ...
c++11/15/2009
  Q: could u pls help mi.i realli realli need alot of help frm u.i still cn't seems to do the interest ...
  A: If I understand correctly, for each customer, you have to print out the accounts and investments ...
Sorting and Searching Array Problem11/15/2009
  Q: My name is Ernest. I am trying to teach myself C++. I am currently working on a C++ problem that I ...
  A: I really appreciate you making an attempt at solving the problem. It shows you are serious, and have ...
what could be wrong with my code?11/14/2009
  Q: i am not sure but could it be that i already deleted the memory to store the object cuz i cant ...
  A: Yes, you are freeing memory when you don't want to. When you call int neg(dyna ob) { return ...
c++11/14/2009
  Q: could u pls help mi.i realli realli need alot of help frm u.i still cn't seems to do the interest ...
  A: Lisa, where you have //////////////////////////////////////////////////////// // Print out ...
GCC vs MSVC++ compilation11/13/2009
  Q: I am about to lose my mind and hoping you can prevent it. Background: As part of a much-too-low ...
  A: I'm glad I could help. I'll address your questions. 1) File scope: The vector rundata was ...
Graphics initialising error11/13/2009
  Q: Sir,I am using Turbo c++. While running the graphics programs I am getting BGI error as "graphics ...
  A: Perhaps you are not calling initgraph correctly. initgraph(&gd,&gm,"..//bgi"); The // indicates a ...
GCC vs MSVC++ compilation11/13/2009
  Q: I am about to lose my mind and hoping you can prevent it. Background: As part of a much-too-low ...
  A: Hang on to your mind. When you're dealing with this quantity of data, you should stay away from the ...
c++ switch, and functions11/12/2009
  Q: My syntax for the switch statement looks correct but I get case 2, 3, ... label not in switch ...
  A: Chris, if you consider a word to be characters delimited by spaces, then this function will do what ...
c++ switch, and functions11/12/2009
  Q: My syntax for the switch statement looks correct but I get case 2, 3, ... label not in switch ...
  A: Chris, I corrected the syntax errors. My comments start with //--- I did not check any logic. I'm ...
Career Opportunity11/11/2009
  Q: I've almost finished my first year at university and I want to know if I should try find an ...
  A: I think getting practical experience is an excellent idea. It gives you a chance to learn, and to ...
c++11/10/2009
  Q: i did nt gt frustrated.it is veri hard.i am trying veri hard to understand the program. i hv ...
  A: This assignment is certainly getting complicated. Here are my comments for your latest code. I have ...
c++11/9/2009
  Q: could you pls help mi,i realli realli need your help.i'm hving a veri hard time doing it.i'm trying ...
  A: Please make sure you read my suggestion at the end before making changes to your code. Here are ...
c++11/7/2009
  Q: could you pls help mi,i realli realli need your help.i'm hving a veri hard time doing it.i'm trying ...
  A: Your program does not compile. I have made corrections to the program to make it compile. The code ...
computing the area of a triangle11/7/2009
  Q: i have an assignment due on computing the are of a triangle using 3 functions...my teacher really is ...
  A: The toughest part of this sort of assignment is handling the user's input. You have to handle ...
c++11/6/2009
  Q: could you pls help mi,i realli realli need your help.i'm hving a veri hard time doing it.i'm trying ...
  A: You've made a good start defining the types of classes you need but you are having trouble reading ...
problem in c++ project11/3/2009
  Q: i had prepared following project in c++.suppose if i enter 10 accounts than delete any account ...
  A: I commend you for doing so much of your assignment. I've tested all of the functions and made slight ...
which language to use for developing apps10/31/2009
  Q: I've a strong attitude towards programming, software engineering. I want to develop some cool apps ...
  A: That is a good question. I've never used Java professionally so I don't know how it's used in ...
maze algorithm10/30/2009
  Q: I was taken an experiment that is the solution of maze problem, but I cannot solve it.I can find ...
  A: I'm happy to help but I cannot say why you are finding only one solution without seeing your code. I ...
I am confused with my program10/28/2009
  Q: I am trying to write a program that will read students names and 3 grades from a file. then the 3 ...
  A: You have not told me what part of your program is giving you trouble. I will give you a bit of code ...
8 Queens10/26/2009
  Q: my problem is about 8 queens problem by Using an exhaustive technique,my problem is that what ...
  A: Bita, I cannot say what the problem is from this code fragment. Please post the entire program. If ...
c++10/26/2009
  Q: could u pls help mi,i realli need your help.i am trying to do a simple addition of using class ...
  A: If you have not done so, make sure you have declarations of your new functions in the myVector ...
c++ input check10/25/2009
  Q: I am a beginner programmer and I've been trying to code a small game (something similar to PONG). In ...
  A: Alex, the problem is that if (kbhit) does not call the kbhit function, it simply returns the ...
c++10/25/2009
  Q: could u pls help mi,i realli need your help.i am trying to do a simple addition of using class ...
  A: That's very strange. I cannot reproduce the problem. No matter what I do, it allows me to enter both ...
c++10/24/2009
  Q: could u pls help mi,i realli need your help.i am trying to do a simple addition of using class ...
  A: That's pretty good. But you need a few changes to make it compile. In C++ you cannot have a variable ...
to accept characters and cost of a node10/23/2009
  Q: ....am supposed to submit this on monday. the problem am facing is to accept a character instead of ...
  A: I am trying a little experiment. I've written a short tutorial on binary trees on google documents. ...
linking loader...no errors but it doesn't produce the right output10/23/2009
  Q: ....i have some problem with the code below. it has no errors but does not produce the right ...
  A: I'm certain that you don't intend your first program to read pass1.c. Maybe it's supposed to read ...
to accept characters and cost of a node10/23/2009
  Q: ....am supposed to submit this on monday. the problem am facing is to accept a character instead of ...
  A: I am having some difficulty understanding your question and I'm not sure what your program is to do. ...
BMP in c++10/22/2009
  Q: i am a university student and i want to Write a C/C++ program that extracts the width and height of ...
  A: You need to know the format of the bitmap file. I assume you are asking about the windows bitmap ...
C++ Perfect Numbers10/22/2009
  Q: I just joined a programming club and we have to do problems to improve our knowledge from time to ...
  A: A computer club is fantastic! I suppose you like puzzles and don't want the answer given right away. ...
linking loader...no errors but it doesn't produce the right output10/21/2009
  Q: ....i have some problem with the code below. it has no errors but does not produce the right ...
  A: Perhaps I misunderstood what the program is supposed to do when I said that the input file should be ...
linking loader...no errors but it doesn't produce the right output10/21/2009
  Q: ....i have some problem with the code below. it has no errors but does not produce the right ...
  A: The program has a number of problems. At the end of my message is a list of warnings produced by the ...
Simple program C++ one small problem10/20/2009
  Q: Im putting through this program and its running but it ends with this "error" The thread 'Win32 ...
  A: Andrew, I'm not getting that behavior. I see The program '[1208] Test.exe: Native' has exited with ...
C++ classes10/19/2009
  Q: I am trying to ask user for input which is string type. Then I use pointer to point to that string ...
  A: Hey bro! In the line string* UI_ptr; you are declaring that UI_ptr is a pointer to a string. Later ...
hi10/17/2009
  Q: what does they do?and how can i remember them easily? also how can i remember for,while,and do while ...
  A: The c++ string is an object that represents a sequence of characters. You can add characters to it ...
process and thread priority10/13/2009
  Q: In my application, there are two threads. I want to set one of them the highest priority, and the ...
  A: Xiyuan, I am just responding to this follow up to remove it from my pending list. As I said in the ...
process and thread priority10/13/2009
  Q: In my application, there are two threads. I want to set one of them the highest priority, and the ...
  A: According to the documentation the actual priority of a thread is a combination of the priority ...
process and thread priority10/12/2009
  Q: In my application, there are two threads. I want to set one of them the highest priority, and the ...
  A: According to the documentation, the pseudo handle is interpreted as the current process for ...
Simple program i just cant get10/11/2009
  Q: I have an online class and i just cant get the hang of how this is supposed to work, ive tried some ...
  A: Andrew, the problem is that C/C++ does not use the words "then" or "and" as part of the "if" ...
process and thread priority10/11/2009
  Q: In my application, there are two threads. I want to set one of them the highest priority, and the ...
  A: In my experience, SetPriorityClass and SetThreadPriority are the only two functions you need to ...
hi9/29/2009
  Q: hi can you explain to me in detail whats a pointer and array with examples and how they work?
  A: This is a big open question, so my answer may cause you to have more questions, but that's OK. Just ...
help me!!!!9/28/2009
  Q: Write a program that computes the cost of a long-distance call. The cost of the call is determined ...
  A: I will try to help you, but you have not told me what you have tried or what you are having trouble ...
help me!!!!9/28/2009
  Q: A public utilities company in in a city wants to track the status of its power service throughout ...
  A: Sir, I'll help you with the get_grid and display_grid, and you can then finish your assignment using ...
C++ Doubt9/27/2009
  Q: How to increment the empid e001 to e002 by using the coding? Please mail me the coding to my ...
  A: I am not sure that I understand your question. If you have a variable called empid and it is an ...

All Questions in This Category

C++

All Answers


Answers by Expert:


Ask Experts

Volunteer


Zlatko

Top Expert on this page

Expertise

I can answer questions about C / C++ programming, software design, algorithms, and interprocess communication. I have access to Microsoft Visual Studio and gcc as my development platforms.

Experience

I have been developing software professionally for UNIX and Microsoft Windows since 1991.

Education/Credentials
I have a Bachelor of Applied Science in Computer Engineering from the University of Waterloo located in Waterloo, Ontario, Canada.

©2012 About.com, a part of The New York Times Company. All rights reserved.