Visual C++ :: How New / Delete Store Internal Info About Allocated Buffer

Dec 9, 2014

I am using C++ new/delete operators to allocate/deallocate the buffers. I think for each allocated buffer, there should be an additional info block stores the size and other info about the buffer. How to know more details about this info block? I need to override these two operators and find such an info block is useful to my implementation.

View 3 Replies


ADVERTISEMENT

Visual C++ :: How To Determine Size Of Allocated Buffer

Dec 9, 2014

I use new to allocate a buffer, as follows:

BYTE *p;

p = new BYTE[20];

If I do NOT store the size of the allocated buffer, how to determine the buffer size via p only?

View 6 Replies View Related

C++ :: How To Store Class Info Entered By User Into Array

May 7, 2013

So I have an array of my own class, "Restaurant," but I'm having a hard time figuring out how to store the info entered by the user into the array.

In total, I have two classes. I will show you all I have, it's a lot but I know it will be easier to understand.

My problem is in the AddRestaurant(), since that is where I should ask the user for all the information and store it in the array.

Also consider that I have to use the FTime class as well to handle the time. Basically I want to do something like this:

info[count].SetRating();

which will put the rating part of the class Restaurant into the array[count]

Also, my program doesn't compile because of the AddRestaurant and PrintAll functions since what I am showing is what I want to do, not what works.

//main.cpp
#include <iostream>
#include <iomanip>
#include <string>
#include "Restaurant.h"
#include "FTime.h"
int ReadMenuChoice();

[Code] .....

View 4 Replies View Related

C/C++ :: Program To Store Info About Students And Then Display To Screen

Oct 7, 2014

NOTES AT BOTTOM---EXPLANTION, PROBLEMS ETC. SCROLL DOWN

#include <iostream>
#include <iomanip>
#include <string>

[Code]....

I have to write a program that stores information about students and displays results (Formated). Example-

Inputs ( # of students, First and Last name of student, the gender, age, and hieght. (height inputed as inches and outputed as feet and inches))

Student 2
---------
Jett, Joan Female
100 years old 5' 7"

Ive been falling behind a little due to working late and barely having time for my school work. Coming across several issues, one being an error with GENDER (Error C4700: uninitialized local variable 'gender' used:). As well as how to format the end result, i understand that u have to use #include <iomanip>, but am confused on how to format correctly.

View 2 Replies View Related

C++ :: Doubly Linked List That Will Store Strings - Delete Function

Sep 23, 2014

I am creating a doubly linked list that will store strings, for example:

struct node{
string data;
node* next;
node* prev;
};

node* head; //first element from left to right (global)
node* tail; // last element from left to right (global)

And here is the function:

void deleteNode(int n){
struct node* temp1 = head;
if (n == 1){
head = temp1->next;
free(temp1);

[Code] .....

View 3 Replies View Related

Visual C++ :: How To Get Same Info As Win32 PortConnector From DeviceIoControl

Mar 21, 2013

I can tons of information by calling DeviceIoControl (such as device ID, device description, whether it's connected or not) since I couldn't do it all with WMI. But I haven't figured out how to get from DeviceIoControl the info that a call to WMI's Win32_PortConnector gets. Are there any calls, directly to DeviceIoControl or something else that for a given device ID or device description would get the PortConnector information?

I would have used a combination of Win32_PortConnector and DeviceIoControl calls but the trouble with PortConnector is that it doesn't provide any information that would allow one to figure out which device ID it belongs to. Why do I need to do this? Because I'd like to get a combination of all the information the two methods provide for a given device such as a USB port, and all I'm getting from Win32_PortConnector is these scant few fields with no other clue:

string Caption;
string ConnectorPinout;
uint16 ConnectorType[];
string CreationClassName;
string Description;
string ExternalReferenceDesignator;
datetime InstallDate;

[Code] ....

View 1 Replies View Related

Visual C++ :: Create A File That Ask The User To Enter His Info

Nov 9, 2014

What I want to do is create a file that will ask the user to enter his info,n then store it in a text file The screen will ask the user if he wants to update his info. if he says yes then the screen will be cleared and the old info will be printed on the screen. The user will enter his new info that will be stored in a new file. My problem is that once the user finishes entering his input the program just closes D: and the rest of the program won't run.

Code:

int main()
{
string ans;
ofstream Xfile("original.txt");
cout <<"Enter your name and address please"<<endl;
cout<<"Press Ctrl+Z+Enter when you are done"<<endl;
string name_and_street;

[Code]...

View 3 Replies View Related

Visual C++ :: Draw Buffer With Raw Data?

Nov 19, 2012

Got buffer with raw data. How to display it in MFC dialog and refresh it?

View 3 Replies View Related

Visual C++ :: How To Create Image Buffer In MFC

Jan 27, 2013

how to create, initialize, and maintain a memory device context that works as a local buffer for images? The idea is to maintain some large images in local DCs and bitmaps, and only bitblt them to screen in OnDraw().

What I did so far was was to define CDC and CBitmap objects as members of my View class, and then tried to initialize them with the sequence that begins at "// Initialize buffer". I placed that sequence in either OnInitialUpdate, or PreCreateWindow, or OnPrepareDC, or the view constructor, to no avail. The code always crashes in OnDraw, and I've noticed that the m_hDC member of myDevice is zero at that point.

Obviously, the initialization is wrong and MFC does (too many) things in the background which I'm not aware of.... My question was where can I read about that?

Code:
class CMyView : public CScrollView {
// ...
CDC myDevice;
CBitmap bmp;
CBitmap *oldbmp;

[Code] .....

View 5 Replies View Related

Visual C++ :: How To Determine If A Buffer Is Freed Or Not

Dec 9, 2014

I use new to allocate a buffer, as follows:

BYTE *p;
p = new BYTE[20];
...
delete p;

After p is deleted, if I do NOT assign NULL to p, is there a way to determine whether it has already been freed?

View 4 Replies View Related

C++ :: File Writing - Input Your Login Info And Program Writes That Info To A Text File

Jan 30, 2013

I'm trying to make a program that you input your login info and it writes that info to a text file. Then, later on once I get my problem fixed, the program will read the info to the user. my code is as follows(the input part is a bit lengthy):

// Password Log
#include <iostream.h>
#include <fstream.h>
#include <string>
#include <time.h>
using namespace std;
ofstream login;

[Code] ....

What my problem is when I choose "Input new login info" it automatically inputs I have no clue, and calls next program.

View 3 Replies View Related

Visual C++ :: Bitmap Display From Buffer Received By TCP Socket

Feb 6, 2013

I want to display my image on window without saving it.

When data is received window size changes but there is no display on window.

My Code is:

Code:

int iBufferLength;
int iEnd;
int iSpaceRemaining;
int i;
iBufferLength = iSpaceRemaining = sizeof(chIncomingDataBuffer);
iEnd = 0;
iSpaceRemaining -= iEnd;

[code].....

where I'm doing wrong?

View 1 Replies View Related

Visual C++ :: Playing Video Using Windows Media Player From A Buffer?

Oct 25, 2013

I am developing a VC++ application with windows media player component. play video from a video buffer data which i have?

View 2 Replies View Related

C++ :: Speech Synthesis With Internal Speaker?

Mar 19, 2013

I am programming an old-school dungeon crawler and thought it would be cool to get the pc's internal speaker in on the action. While Ive used the BEEP function to nice effect for generating music, how I would go about getting speech out of my internal speaker?

View 2 Replies View Related

Visual C++ :: Access Violation Reading Void Assigned Dynamically Allocated Value Inside Function

Sep 16, 2013

Why the void pointer passed to testb doesn't continue pointing to the allocated integer after the function call returns.

Code:
#include <stdio.h>
#include <iostream>
void* testa() {
return new int(1);

[Code] ....

View 5 Replies View Related

C++ :: Delete Specified Names From A List Of Store Names?

Feb 10, 2013

i have a vector of stores. i would like to delete the specified choice(store) from the list. Here is what i have but my erase statement is wrong and wont compile.

void Store::deleteSpecifiedStoreFromList(string choice) {
for (int i = 0; i < this->stores.size(); i++) {
if(this->stores[i].getStoreNames() == choice) {
this->stores.erase( std::remove_if( this->stores.begin(), this->stores.end(), choice ), this->stores.end() );
}
}
}

View 4 Replies View Related

C :: Test Is Not Recognized As Internal / External Command

Sep 11, 2013

My prog name is test and the problem is when i compile it gives error : 'test' is not recognized as an internal or external command,operable program or batch file.

Code:

#include <stdio.h>
#define ISDIGIT(y) ( y >= 48 && y <= 57 )
main( )
}

[code].....

View 14 Replies View Related

C++ :: Enable Client To Iterate Internal Vector

Nov 26, 2012

The example enable a client to iterate the internal std::vector using being() and end().

Code:
class foo {
public:
typedef std::vector<std::string>const_iterator iter;
iter begin () const;
iter end () const;

[Code] .....

In the future I see the need for this class to be able to control sequence (sorting) and also show a subset of the complete list based on a search parameter.

Using std::sort appear to solve the ability to sort the collection.

How can I return an iterator to the client which only iterates a sub-set of all items in the std::vector?

An example would be, I add this method to the class;

Code:
void find(const std::string& st);

So if the client performs (below) only items in std::vector that contains the character "a" should be possible to iterate.

Code:
foo f;
f.search("a");

One option would be to operate with two collection inside the foo class. One more static containing all items and the other containing the sorted and filtered items. This would lead to some copying but should work. Far from perfect.

View 2 Replies View Related

Visual C++ :: Serial Communication In Windows - ClearCommError Finds No Data In Read Buffer

Dec 13, 2013

I want to send data from a laptop (windows 7, processor 2.60GHz) to a desktop (windows xp, processor 3.10GHz) using serial communication (using a USB to RS232 convertor). The WriteFile function is able to send the data from the laptop (NumberOfBytesWritten is correct). But on the desktop side, ClearCommError detects no data in the read buffer.

This is the relevant code in my desktop:

while(1) {
ClearCommError(hPort,&dwErrors,&commStatus);
if (commStatus.cbInQue != 0) ReadFile(hPort,&data,1,&dwBytesRead,NULL);
Sleep(10);
}

The if condition is never satisfied. The baudrate and other parameters in the DCB struct are the same on both sides.

The same code works when I write and read in the same system by shorting the RX and TX pins in the RS232 connector.

View 2 Replies View Related

Visual C++ :: Circular Buffer - No Instance Of Overload Function Matches Argument List

Nov 25, 2014

I'm having some issues with my code. For the produce function i am getting an error saying 'no instance of overload function produce() matches the argument list' and also for the lines buffer[head].data = message; buffer[head].time = current_time i get an error saying 'expression must have pointer to object type.

In the code i'm not sure if i passed the variables to the function correctly. I have attached the code .....

code produce.txt

View 14 Replies View Related

C++ :: Declare A Struct / Class In A File For Local Use But With Internal Linkage?

Mar 15, 2013

I've been wondering about something for a while:

Is it possible to declare a struct/class, in a cpp file, designed for local use, but with internal linkage?

The usecase is that every once in a while, I want to wrap "startXXX+endXXX" function pairs in a simple RAII struct. I just declare the struct in my cpp and use it once.

However, if I do this, (AFAIK), the compiler will generate an entry in the link table, which means I could potentially have link conflicts if I declare the same struct twice in two different cpp files.

Unless I'm mistaken, since the struct is declared in the same cpp that it is used, I wouldn't need external linkage. Is there a way to avoid it?

View 6 Replies View Related

Visual C++ :: How To Delete Records In TXT File

Nov 19, 2014

I have to ask the user if they want to delete any records. The user can enter -1 to finish deleting records. I have to write the remaining records in an output file. I have this, but 1) it doesn't let me enter more than 1 id, and 2 it doesnt output anything to my output.txt.

records.txt
6
123 Jose Garcia 99
345 Luis Garcia 87
234 Jazlyn Soriano 79
456 Carter Sander 95
567 Natalia Soto 67
789 Isabel Santana 80

Code:
#include <iostream>
#include <fstream>
#include <cstdlib>
#include <string>
using namespace std;
class Student {
private:
int id;
string firstName;

[Code] .....

View 9 Replies View Related

Visual C++ :: Retrieving Size Of Each String In Order To Produce A New Buffer For Concatenated String

Feb 25, 2013

What is the efficiency of the two assignments (line 1 and 2), i.e. (function calls, number of copies made, etc), also the Big O notation. I know there are function calls for retrieving the size of each string in order to produce a new buffer for the concatenated string...any difference between line 1 and 2 in terms of efficiency?

String s("Hello");
String t("There");
1. s = s + t;
2. s += t;

View 3 Replies View Related

Visual C++ :: Detect ItemID And Delete That Line From File

Oct 14, 2013

I have a text file name fruit.txt that contains the following information of fruit id, fruitName and fruitQuantity.

Code:
1:pear:30
2:apple:20
3:banana:24
4:orange:15
5:watermelon:35

If let's say I key in 2, it will search for the id=2 and delete the whole line and the id of banana which is orignially 3, will become 2 and orange which is orignally 4 will become 3 etc.

I researched on how it can be done and most suggested to put inside a vector and fout the line.

I know how to put the values in the vector but how should I go about searching for the id and if the id is found it will delete that line inside the file.

Code:
ofstream fout;
ifstream readFile("fruit.txt");
while (getline(readFile, line)) {

[Code]....

View 2 Replies View Related

Visual C++ :: Reverse String Sequence In String Buffer

Apr 27, 2013

I made a simple little program that takes text from the clipboard, and spits out all the lines I've copied one at a time (so my program can analyze it).

everything works perfectly, except, it spits it own in the wrong order, I want it to spit out from bottom to top. but currently it spits out the data from top to bottom. here is my code :

Code:
#include <iostream>
#include <Windows.h>
#include <string>
#include <sstream>
using namespace std;
int main() {
HANDLE clip; // assigns the var. clip to hold a handle ID.

[Code] .....

I want this loop to run backwards! Like it say's what I want to work backwards. Where as I know how to flip a while loop like this: while(x < 5), how to flip a loop like the one I'm using. how I can do this?

View 8 Replies View Related

Visual C++ :: Delete Earlier Dynamic Controls And Redraw In Dialog

Apr 6, 2015

I've created a dialog based MFC app which input from user to create that many dynamic controls(Used checkbox to be created dynamically).

After user input that many checkboxes controls are created but if try to click again then not able to delete previous controls and again new no. of controls.

Code snippet to add controls on user input.

RECT rctA;
rctA.top = 51;
rctA.bottom = 80;
CString temp;
m_Edit.GetWindowText(temp);
int noOfControls = _tstoi(temp);

[Code] ....

View 1 Replies View Related







Copyrights 2005-15 www.BigResource.com, All rights reserved