C++ :: Clear Data From Char Array?

Feb 5, 2013

How to clear data from a char array?

View 19 Replies


ADVERTISEMENT

C++ :: Encrypt Char Array With Binary Data

Apr 14, 2013

I am trying to encrypt a char Array with binary data.

I think I understand the basic of Encryption / Decryption but I fail to see how to implement something.

I am trying to have a "key" that needs entered so the data can become readable executable. The program I am encrypting is a small console window with a message with the text "A secret message from your friend" (Not that it matters).

I have the binary data witch I can copy and what not. But how go about Encryption and then decrypt it and not destroying the data.

View 6 Replies View Related

C/C++ :: Clear First Character Of Array

Mar 26, 2014

I am trying to clear the first character of my array. The first two methods don't seem to work. The third method seems to but doesn't look like a good idea.

char operand[] = "abc";
//both methods seem to null it out
operand[0] = 0;
memset(operand, 0, 1);
printf("%s", operand);

//seems to work
memset(operand, 5, 1);

View 4 Replies View Related

C++ :: Read Byte Of Char Data And Convert It Into Text String Of Binary Data That Represents Hex Value

Dec 26, 2013

I am writing a program where I need to read a byte of char data and convert it into a text string of binary data that represents the hex value...

i.e. The char byte is 0x42 so I need a string that has 01000010 in it. I've written the following subroutine....

------------- My Subroutine ----------------------------------------------------------------------
void charbytetostring(char input, char *output){
int i, remainder;
char BASE=0x2;
int DIGITS=8;
char digitsArray[3] = "01";

[Code] ....

When I submitted the byte 0x42 to the subroutine, the subroutine returned to the output variable 01000010... Life is good.

The next byte that came in was 0x91. When I submit this to the subroutine I get garbage out.

I am using a debugger and stepped through the subroutine a line at a time. When I feed it 0x42 I get what I expect for all variables at all points in the execution.

When I submit 0x91 When the line remainder = input % BASE; gets executed the remainder variable gets set to 0xFFFF (I expected 1). Also, when the next line gets executed..

input = input / BASE; I get C9 where I expected to get 48.

My question is, are there data limits on what can be used with the mod (%) operator? Or am I doing something more fundamentally incorrect?

View 6 Replies View Related

C++ :: Comparing Char Array To Char Always Returns True

Dec 23, 2014

I've made a code to check whether or not a save file has been created correctly, but for some reason it always returns this line: readdata[qa]=='1' as true. in which qa is the counter I use in a for loop and readdata is a character array consisting of 50 characters that are either 0, 1 or 2.

this is the entire code:

#include <iostream>
#include <fstream>
#include <string>
using namespace std;

[Code]....

at first is also went wrong at line 22 and also returned that as true, but then I added brackets and it worked.

View 4 Replies View Related

C++ :: Concatenate Two Char Arrays Into Single Char Array?

Sep 29, 2014

I am trying to concatenate two words from a file together. ex: "joe" "bob" into "joe bob". I have provided my function(s) below. I am somehow obtaining the terminal readout below. I have initialized my memory (I have to use dynamic, dont suggest fixing that). I have set up my char arrays (I HAVE TO USE CHAR ARRAYS (c-style string) DONT SUGGEST STRINGS) I know this is a weird way to do this, but it is academic. I am currently stuck. My file will read in to my tempfName and templName and will concatenate correctly into my tempName, but I am unable to correctly get into my (*playerPtr).name.

/* this is my terminal readout
joe bob
<- nothing is put into (*playerPtr).name, why not?
joe bob joe bob
seg fault*/
/****************************************************************/
//This is here to show my struct/playerInit

[Code]....

View 2 Replies View Related

C :: Char Array With A Phrase To Char Word

Nov 28, 2013

I need to do a function that copy every word from a text to a char word. How can i do it?

View 5 Replies View Related

C :: Getting Int Data From Char

Apr 4, 2013

developing an algorithm with use of minimum system resources. I have an embedded board with sends data through rs232 port to system.

the moment i give the command it starts transmiting data to my pc(buffer array) Now the first 317 bytes are read as strings and i am able to get that read successfully.

The rest of the data is to be read in int form.i.e 2 bytes(short int) short quick way to read int data without much manipulation(which may cause loss of data as baudrate is very high).

Here is what i have going so far: Code: ///Reading Data
// while(rzBuff[0] != '
')
for(i=0;i<=318;i++)

[Code].....

View 4 Replies View Related

C++ :: Char Data Type Variable

Jun 12, 2013

I have two char variables, m_GPSOffset[13] and m_FileName[100]. When m_GPSOffset has a value assigned to it, say for instance +11:25:30. The first entry of the value, in this case +, is always stored in m_FileName. I am clueless on why this is occurring.

View 15 Replies View Related

C/C++ :: How To Clear Nested Stl Map

May 21, 2013

here is a nested stl map

typedef struct struct_RISCP {    
        float nSCPTotal;
        int nSCPCount;
        CString strIMEI;  
        std::map<UINT8, int> mapSection;    
    }RISCPSt;
map<stRncCellIdntyDmnType, RISCPSt>m_mapRISCP;

it occupied too much memory,i wanted to clear them(both outer map and inner map) ,some one told me you just need to call m_mapRISCP.clear(),then the mapSection (inner map) will be cleared automaticly,in other words, m_mapRISCP.clear() will clear both outer map and inner map.

View 5 Replies View Related

C++ :: Clear Screen Without Blinking

Nov 4, 2013

I have a one simple question :D. I want to output to the console some symbols. Let's say that i have a loop.

for(int i = 0; i < 10; i++) cou << "* ";

Then I want to output other symbols but I want to overwrite the previous symbols. I know I can use system("cls"); but it blinks if I try to output the same characters. For example if I have:

for(int i = 0; i < 10; i++) cou << "* ";
system("cls");
for(int i = 0; i < 10; i++) cou << "* ";

After I run this code the first loop outputs ten "*". Then there is a blink and there are again ten "*" shown. How can I avoid this blink?

View 4 Replies View Related

C++ :: Difference Between Erase And Clear

Apr 4, 2014

vector<int> *vec; allocate memory and

suppose vec conatins 10 values then

erase(vec->begin(),vec->end());

vec.clear();

both should be used or any one one is fine to erase all ??

View 1 Replies View Related

C++ :: Clear Part Of The Screen?

Nov 3, 2014

Is there any way I can clear only a selected part of the screen? (I'm aware of system("cls"))

For example, when you enter a date, and is wrong, could it just errase that input and only say "Wrong try again" without errasing everything else you where doing?

In this case, a function that only errases what is in the while

while(not wrong)
{
cout<<"DIA: ";
cin>>obj.dia;
cout<<"MES: ";
cin>>obj.mes;
cout<<"ANIO: ";
cin>>obj.anio;
}

PS: Also, is there any whay in which you can ask the user to enter the date DD/MM/YYY?

View 1 Replies View Related

C# :: Clear A Listbox From A Class?

Jun 5, 2014

I need to clear a listbox from a class other than the form where it exists. Why this isn't working? I'm getting no error messages when I compile and I am seeing the Console.WriteLine text I also added in the same function. I can call this function from within my form and it behaves as expected. I tried setting the listbox to public despite the fact I wasn't getting protection level errors but that made no difference.

Just to clarify what I'm doing here... I have a form that includes a panel of user controls from another class. So there is a listbox on OtherClass and the listbox is in MyForm. Heres my code:

MyForm

public void ClearListBox() {
Console.WriteLine("echo");
listBox.Items.Clear();
} OtherClass
private void listBox_SelectedIndexChanged(object sender, EventArgs e) {
MyForm mf = new MyForm();
mf.ClearListBox();
}

View 9 Replies View Related

C++ :: How To Clear A File At Beginning Of Program

Jul 28, 2013

I'm writing a program that converts hex to letters and writes the letters to a file.To write I'm currently using ofstream("output.txt" ios::app)But the issue with this is, is that everytime I run the program, it appends and doesn't write from the beginning of the text file.So what I want to know is, how do I clear the contents of a text file, before writing to it?

View 1 Replies View Related

C++ :: How To Clear Exception Mask For A File

Feb 12, 2015

When creating an exception mask for a file, should an exception throw during a file operation, I can reset the state bits of the actual file using ios::clear().

Though after doing so, will the exception mask still throw an exception, thinking that the specified error state flags are still set to true? If so, how can I reset the exception mask so that it is ready to throw more exceptions should the appropriate situations arise in the future?

View 2 Replies View Related

C++ :: Osstream Doesn't Flush Or Clear

Dec 15, 2012

Code:
std::ostringstream ss;
ss.flush();
ss.clear();
ss << v.x;
std::string buff(ss.str());
XMLString::transcode(buff.c_str(), tempStr, 99);

[Code] ....

The buff at "Z" are stringed together with previous values. How do I resolve that?

View 5 Replies View Related

C :: Visual Studio 2012 - Writing Data Into TXT File / How To Stop Reading Char

Feb 23, 2013

I am using visual studio 2012.....in below code i m writing data in to a test.txt file but i dont know with which key file stop accepting char...i tried ctrl+z and ctrl+d but not working ....

Code:
#include<stdio.h>
#include<conio.h>
main(){
char ch;
FILE *ptr;

[Code] ....

View 7 Replies View Related

C :: Parsing Char Array To Array Of Struct To Process Packets

May 28, 2013

I wrote this simplified version of a program i am writing that parses data in UDP packets. In the process of doing so i pretty much answered all my questions and fix all the problems i was having.

decodeSystemMap function will be in loop, and will proccess packets that have mostly the same data, only a few items will be added or changed or deleted.

whats the best way to check if there are any new, deleted, or removed items in the packet and only modify those?
Is there anything unsafe / dangrous about the way the code is now?

Code:
/* * File: main.c
* Author: david
*
* Created on May 23, 2013, 11:57 AM
*/

#include <stdio.h>
#include <stdlib.h>

[Code] ....

View 4 Replies View Related

C++ :: Using Clear Device And Sleep Functions In Graphics

Dec 14, 2014

I have a college project which is a car racing game using C++ and the old-school graphics library BGI. After I draw the map and placed the objects(Car,obstacles,road's borders etc..)I added Sleep(); function to the function named Obstacles(); but the problem is, I can't move the car with the right&left arrows.a

Another problem,If I added a cleardevice(); command all objects disappears only the obstacles function keeps working. the Code is here:

char c;
do{
c = (char)getch();
if (c == KEY_LEFT) {
x = x - 10, x1 = x1 - 10;
} if (c == KEY_RIGHT) {
x = x + 10, x1 = x1 + 10;

[code].....

note: this is not the whole code, it's only a small portion of it, not a debugging question only need a hint how to fix it.

View 3 Replies View Related

C++ :: Clear Screen For Microsoft Visual 2010?

Jan 11, 2013

I checked through the net and most of the solution like clrcr(); is not working for microsoft visual 2010. SO i was wondering for those who was using the same ver of c++ as me how do you clear the screen?

View 5 Replies View Related

C# :: Datagridview Combobox Selection Clear After Adding New Row

Dec 25, 2014

I have 2 datagridview in one windows form, When I click row from datagridview1, it shows in datagridview2 (Select *from....). Also I have combobox column in datagridview2. My question is, when I select items in combobox, and click to new row in datagridview 1, datagridview2 combobox's is getting empty. it is my code:

private void dataGridView1_CellDoubleClick_1(object sender, DataGridViewCellEventArgs e) {
try {
int id = Convert.ToInt32
(dataGridView1.Rows[dataGridView1.CurrentRow.Index].Cells["id"].Value);//3

[Code] .....

View 8 Replies View Related

C# :: Clear White Space On Random Tile Map

Mar 14, 2015

I've got myself a 2d array

int[,] map = new int[100,100];

I've populate that will a bunch of 1's and 0's. The 1 represents a wall, and a 0 is dirt.

I'm looking for a way to clean up my blank spaces outside of my walls. Any algorithm I can use to identify these big areas and replace them with a '1'

for (int y = 1; y < map.GetLength(1) - 1; y++) {
for (int x = 1; x < map.GetLength(0) - 1; x++) {
// Inside here is where I was hoping to archive my work
bool draw = true;
foreach (Room room in rooms)

[Code] ....

Attached is an example of my output.As you will be able to see, there is a lot of brown. I want to fill the brown with walls, but leave space for a path between the rooms.The 'draw' bool is true when I'm outside of a room, just so I don't start throwing walls inside my room.

Example of what the array would look like (for those who don't know)

int[,] map = new int[100,100]
{
{0,1,1,1,1,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,0,0,0,1,0},
{0,1,1,1,1,1,0},
};

View 6 Replies View Related

C++ :: Convert Uint8 Array To Unsigned Char Array?

Mar 2, 2012

I have the following code which attempts to assign a u_int8 array of 256 to an unsigned char[256]:

Code:
unsigned char testData[256]=pSample->data;

I get the compilation error:

error C2440: 'initializing' : cannot convert from 'const uint8_t [256]' to 'unsigned char [256]'

What is the safe way to cast or convert here?

View 3 Replies View Related

C++ :: Clear Screen In Console - Change Text Color In EXE

Dec 28, 2013

How I can clear the whole screen in console...

And I'm using clrscr(); and its not working.

How i can change the text color in the .exe without using system function

View 4 Replies View Related

C/C++ :: Simple Calculator - Clear Screen Following User Input

Dec 10, 2014

I am working on a simple calculator in C++ .... All works fine with the calculator up until the requirement for the user to input "do you want to go again y/n" .... What i want to happen is the screen to clear down and reloop to the enter name part....but i can't get it to do that

Program Description: To write and develop a programme where a user can input a cost or price of something before VAT our program must then process the input number and must output the price with the original value plus VAT

#include <iostream>// I must use this to start my programming
#include <string> // I have added this for the extension task so the user has to input their name
#include <iomanip> // this is to manipulate the text
#include <stdlib.h>
using namespace std; // using the "using namespace std" shows that i will be using standard text throughout this programme

[Code] .....

View 5 Replies View Related







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