C++ :: Encode / Decode Any Message Based On Given Secret Instructions

Jun 15, 2013

Write a program that will encode/decode any message based on the given secret instructions.

Input
The input shall be composed of 3 parts: A string, maximum length of 255 characters) in a single input line (i.e., terminated by the end-of-line or carriage return) representing the message to be encoded or decoded, A single character identifying the operation to be performed–‘E’ for encode or ‘D’ for decode, and An integer giving the number of columns to be (or that was) used for encoding called the key.

Output
The program shall display the encoded/decoded message. Since the algorithm fails if a sequence of spaces, at least as long as the key, is formed at, and subsequently deleted from, the end of the last column, replace spaces by periods in the output.

Input Validation
None.

Sample Runs

Enter the message: meet me in the park tonight at seven.
(E)ncode or (D)ecode? E
Enter number of columns (key): 5
Encoded message reads: mm.pth.neetaots.e.hrn.e.tiekiav..n..gte.

[Code] ....

View 4 Replies


ADVERTISEMENT

C :: Encode/ Decode Existing EXE File

Dec 28, 2014

Let's say I have an exe-file (for example computer game) and need to forbid to run it until certain date or time during the day. Any 'manipulations' with file are allowed. offer me a simple way of how to encode/decode such a file?

View 7 Replies View Related

C :: Structure Padding To 16 Bytes For Use With Atomic Instructions

Jun 30, 2013

I am using atomic instructions on x64 and variables so used must be 16 byte aligned.

I use a number of structures where their members are so operated upon.

The structures accordingly needs must be 16 byte aligned and padded - their internal members must be on 16 byte boundaries and, crucially, there must be tail padding to a 16 byte boundary, so I can allocate arrays of these structures and use pointer math to iterate. (I am naturally using aligned malloc).

The problem I am finding is that it is not apparent to me how to achieve this end. Here below we have a test structure (currently I'm working with the latest Amazon Linux GCC, 4.6.3, on x64);

Code:
#define LFDS700_ALIGN_DOUBLE_POINTER 16
#define LFDS700_ALIGN(alignment) __attribute__( (aligned(alignment)) )
LFDS700_ALIGN(LFDS700_ALIGN_DOUBLE_POINTER) struct test_element
{
struct lfds700_freelist_element

[Code] ....

I allocate an array of test elements, thus;

Code:
te_array = abstraction_aligned_malloc( sizeof(struct test_element) * 100000, LFDS700_ALIGN_DOUBLE_POINTER );

The problem manifest is that sizeof(struct test_element) is 40 bytes! So the second element does not begin on a 16 byte boundary and we all fall down. Printing the addresses of the first element in the test element array, I see the following;

Code:
(gdb) print *ts->te_array
$2 = {fe = {next = {0x7fffec0008d0, 0x2}, user_data = 0x7fffdc0008d0}, thread_number = 3, datum = 0}
(gdb) print sizeof(struct test_element)
$3 = 40
(gdb) print &ts->te_array->fe.next

[Code] ....

So we see fe->next is the first element and so is correctly aligned curtsey of aligned malloc, where fe->next is 16 bytes, fe->user_data is correctly aligned, but then te->thread_number is misaligned and te->datum is given eight bytes rather than four, leaving us in the end without correct tail padding to a 16 byte boundary.

So, what gives? how *am* I supposed to indicate to the compiler it must pad structures to 16 byte boundaries?

View 8 Replies View Related

C :: Fastest Way Of Changing Elements In Array Of Characters For Encode

Feb 15, 2014

I am wonder what is the fastest way of changing elements in array of characters for encode purpose, here is simple example presenting an idea:

Code:

char *a = "123456789":
char b[] = "ABCDEFGHI";
int 1;
for (i=0;i<strlen(a);i++) {

b[i] = a[i];
}

Is this approach better or worse than bit manipulation ?

View 4 Replies View Related

C++ :: Decode A Table To An Array

Aug 13, 2014

I have recently run into a problem at work in regards to organizing information for some variables in a table and sorting them based on priority values...

For example:

Case ID: 0 1 2 3 4
1 (2 3) (1 2) (5 1) **the first number in the () is the priority*
2 **the second number is the variable id**
3

So from up above (I made it shorter than mine), I have a table with 8 columns for the different cases and 30 rows for the different conditions possible. I am trying to figure out a way to create some type of function that will be able to run through the row and pick the case with the highest priority first (from 1-8), and output the case ID, the priority, and the second number within the brackets.

I thought about creating a decoder that will sort the values and give an array with the outputs, but I know there must be a smarter way to sort the data.

View 1 Replies View Related

C++ :: Decode / Code A Simple Cipher

Mar 1, 2013

So I am trying to make a simple cipher but can't see a pattern between the letters.

Convert:
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
To:
E I L Q A G F R B N T C P J Z M D H X K Y W V S U O

View 1 Replies View Related

C++ :: Error Message While Debugging

Mar 17, 2013

I'm getting an error message that I can't seem to fix. The error clearly states that during the link aspect of the debugging and build there is an error that says that the stdio.h file is either missing, invalid or corrupt. When I try to program using any of the other headers I'm getting the same error. The files are there I can see them in the include folder, so I'm asking what can I do to fix all these headers and beware I am a beginner at programming and using any kind of compiler.

This is the error I receive.
1>------ Build started: Project: hello, Configuration: Debug Win32 ------ 1>LINK : fatal error LNK1123: failure during conversion to COFF: file invalid or corrupt ========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped =========

This is the compiler I am required to use for an online course and all instruction is given for the Microsoft visual 2010 express edition. Also the only file I think that's being referenced is the #include <stdio.h>.

View 1 Replies View Related

C :: Program Terminates Without Message

Jan 15, 2014

I'm trying to parallelize bottom's up merge sort algorithm. Firstly, i must have working procedural code.

I rember I had my code working last week but I made some changes ( probably to arguments passed to sort function ), i run my program several times without rebuilding it so i though it's still working.

Now i came back to my code and my program terminates without any message which confuses me. I debbuged merge function and it seems to work well, at the end i have sorted array.

fprintf doesn't print any value to my stdout.

whole code : [C] mergesort - Pastebin.com

View 4 Replies View Related

C/C++ :: Put Special Chars In A Message

Apr 10, 2014

I'm trying to put in my messages, in my program, some special chars but when i try something like the following code, i get the output below.

#include <stdio.h>
int main( ) {
printf("Trying this char: %c", 160);
printf("Trying this char: %c", 163);
return 0;
}

Output:
Trying this char: �
Trying this char: �

How can i put those special chars? I would like to use: é, ú, ç, à, Ú, À, ...

View 14 Replies View Related

C++ :: Add Error Message If Cin Is Not A Number

Dec 13, 2013

#include <iostream>
#include <stdlib.h> //used for random numbers
#include <time.h>
#include <string>
using namespace std;
int main() {
int bridgeWidth ; //set bridge width to any number

[code].....

View 3 Replies View Related

Visual C++ :: How To Get Rid Of Not Responding Message

Jul 30, 2014

I have a simple dialog based app that performs some time consuming file manipulations. The activating method contains the customary

Code:
CWaitCursor wait;

The hour glass initially appears, than after a few seconds, the dialog title bar indicates 'not responding'.

This is misleading to users as it suggests the application has ceased to function when, in fact, it's working just fine. I would like very much to eliminate this 'not responding' message but havn't a clue how to do it. Have any of you dealt with this problem, if so, how?

View 14 Replies View Related

C++ :: How To Be Able To Type A Message Into Another Program (such As Notepad)

Jul 1, 2013

I want to be able to type a message into another program (such as notepad) using C++. How would I do that? Is there a function to do this, or an event, or something?

View 4 Replies View Related

C++ :: Error Message - Assertion Failed

Nov 12, 2013

I got this message after i delete allocated class object, should i check the deleting? if it's object what is the correct way to delete/delete[]?

theCars[nToDel] is a static array of pointers

bool Cars::deleteElement(int nToDel) {
if (theCars[nToDel] != NULL) {
delete[] theCars[nToDel];
theCars[nToDel]=NULL;
inUse--;
return true;
} else
return false;
}

View 3 Replies View Related

C++ ::  How To Pass A String Variable To Message Box

Feb 20, 2013

I am having trouble finding the solution to printing the contents of a variable. Here is my code:

void OnSize(HWND hwnd, UINT flag, int width, int height) {
std::wstringstream ss (std::wstringstream::in | std::wstringstream::out);
ss << flag;
std::wstring myStr = ss.str();
MessageBoxW(hwnd,myStr, L"Window Resized",NULL);
}

Note, I have #defined UNICODE at the beginning. The compiler tells me this for myStr.

std::wstring myStr

Error: No suitible conversion function from "std::wstring" to "LPCWSTR" exits

View 2 Replies View Related

C++ :: How To Check User Selection (yes / No) On Message Box

Feb 10, 2013

How can you tell what button(yes/no) on a message box is clicked? Below is what I have right now but I am getting errors.

if (MessageBox(NULL,"The Message", "The Title", MB_YESNO) == IDYES){
do something
}

View 7 Replies View Related

C/C++ :: Send Message From Server To All Client?

May 30, 2014

First of all i create single server single client program and then using thread i make multiple client to connect to server.

while(true){
csock = (int*)malloc(sizeof(int));
if(nClient<=maxClient){
if((*csock = accept( hsock, (SOCKADDR*)&sadr, &addr_size))!= INVALID_SOCKET ){

[Code].....

The clients send message to the server and server echo back the message to that particular client. But i want that the server will echo back ones's message to all clients. Suppose 5 clients are connected to the server. So whenever one client send a message to the server, the server will send that message to all 5 clients.

View 1 Replies View Related

C# :: How To Display Output Message Without Using Console

Dec 9, 2014

I was wondering if it's possible to display output message without using console.write or any console function

View 7 Replies View Related

C Sharp :: Send Message From Application

Aug 16, 2012

I want to send SMS through my C# application.

View 1 Replies View Related

Visual C++ :: Edit Message Map At Startup

Apr 17, 2015

Is it possible to edit the message map at startup instead of just having it set at compile time?

I'm reading some values from an XML file at startup. The menu options will be determined from what I find in there. But I need to assign those menu options to the message map.

View 8 Replies View Related

C :: Linux IPC Implement Signal And Slot For New Message

Dec 4, 2014

I'm new in IPC. I would like to implement a signal of a new message, which calls the slot function, eg .:

Code:
msg_on_newMessange(type, &slotFunction);

My code:
Header file: messages.h
Parent file: parent.c
Child file: child.c

How can I do this ?

View 2 Replies View Related

C++ :: Creating A Program That Encodes And Decodes A Message?

Sep 10, 2014

I am starting this project on how to encode and decode messages that are inputted, how to start this?

View 4 Replies View Related

C++ :: System (PAUSE) Without Message Or Button Press

Nov 7, 2013

I would like to have my program pause at a certain screen but not to have the "Press any key to continue..." message or the press of a button. In my program, the code looks similar to this:

for(;;)
{
cout
cin
cout
cin
...
//

here, I want to have a pause to view what the for loop has come up with but to not have a message display or a button press needed. At the end of the loop, I want it to pause before looping again. IS this possible?

If so, how can I implement it into my program?

View 1 Replies View Related

C# :: Using Timer To Refresh Interface - Keep Getting Error Message

Feb 3, 2015

I've been using a timer to refresh the listview on my application, but after half a second, I get the error message at first try/catch method in RefreshPlot() in PlotComponent.cs:

Quote An exception of type 'MySql.Data.MySqlClient.MySqlException' occurred in Marketplace.exe but was not handled in user code

Additional information: There is already an open DataReader associated with this Connection which must be closed first.

View 4 Replies View Related

C# :: Return Message When Fail To Open Database

Oct 3, 2014

I dont know how return message when user fail to open Database.

I building this class to manage db

The "open" method return an OleDbConnection type to manage it later

On catch zone I cant return string , int or other types

class ApriDB {
//Stato interno
string connessione = "";
// metodi
public ApriDB() { } // Costruttore di default
public OleDbConnection open (string connessione) {
OleDbConnection conn = new OleDbConnection(connessione);

[code].....

View 3 Replies View Related

C# :: Grid Column To Always Have 0 Or Change Error Message

Jun 13, 2014

Basically I wanna make my textbox to contain only positive numbers. I was able to do that via masking and regex. I should let you know that the column is bound to a variable which is an int. Therefore, the user always have to type an int (no letters or characters). Like I said, I have been able to prevent user from typing anything but numbers.

Now to the problem:When the user leaves the cell blank and chooses to get out of that cell, they'd get "Input string was not in correct format" next to that cell.

-My approach is: whenever there is nothing in the cell, just replace it with 0. I have code that I thought will do that, but it wont. Seems like the cell was not null, because the if clause won't execute. This is the code:

private void gridView1_CellValueChanged(object sender, DevExpress.XtraGrid.Views.Base.CellValueChangedEventArgs e) {
GridView view = sender as GridView;
if ((view.GetRowCellValue(e.RowHandle, colPriority).ToString() == "") ) {
list.ElementAt(this.gridView1.FocusedRowHandle).priority = 0;
}
}

-Another approach is to change the display or the error message to like "Please enter a number." I have tried doing this but no luck. When I try this concept with the code below, it pops me a dialog box say "Do you wanna change the value?". I dont want it to pop up a dialog box. Also, i was looking for a message that I tried to give it. Looks like it doesn't even get in the if clause because I have checked. And its because its not null? I dont know. This is the code:

private void gridView1_ValidateRow(object sender, DevExpress.XtraGrid.Views.Base.ValidateRowEventArgs e) {
GridView view = sender as GridView;
GridColumn priority = view.Columns["Priority"];
if (view.GetRowCellValue(e.RowHandle, colPriority) == null) {
e.Valid = false;
//Set errors with specific descriptions for the columns
view.SetColumnError(colPriority, "Incorrect Value");
}
}

PS:I have checked that both of these methods get executed, so it isn't like they don't. I used some console.write stuff to check this.

View 2 Replies View Related

C Sharp :: Session Expired Message Show

Feb 27, 2013

How I message show, when session expired?

without web.config

I am working on visual Studio 2008(3.5)

View 1 Replies View Related







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