C :: Search A Requested String And Output Into 16 Byte

Mar 20, 2013

So basically here I have a menu in my C program and if I were to select option 2, I would enter a string up to 30 characters and it would output each block of 16 bytes should be shown which contains a character in the requested string. However, when I compile and run the program and search for the string, nothing happens. what I may be doing wrong?

Code:

else if (select == 2){
printf("Enter a string of up to 30 characters: ");
scanf("%s", &userstr);
//Compares both user's string and file string
for (i = 0; i < size; i++){
if (strcmp (buffer, userstr) !=0){

[Code]...

View 6 Replies


ADVERTISEMENT

C++ :: String To Int To Byte?

Aug 16, 2014

Right now im creating a program that use xbox inputs and then send out keyboard functions using sendInput();

It works fine, but now im creating a system wich lets the user of the program change the settings in a textfile. Wich will then change what the controllers bindings are.

example, if settings.txt says: Y=button(0xIE)

i want the program to know that when xbox button Y is pressed, execute a sendInput function to the Key: A (0xIE).

The problem is that the virtual keycode (0xIE) i take from the settings.txt is stored as a string (lets say it is stored in string Y_event)and input.ki.wScan has to be of type BYTE. i made a function wich changes string into int. (because input.ki.wScan seems to be fine getting a int?)

int stringToInt(string insert) {
char back[20];
for(unsigned int e=0;e < insert.length();e++) {
back[e]=insert[e];
} return atoi(back);
}

but when i run the code nothing happend...

In the code i have a function wich executes the keypress: void pressbutton(int key, int time)

when i send in the converted string it doesn't work but when i send in: (0xIE) it works.

pressButton(stringToInt(Y_Event),50) // doesn't work
pressButton(0xIE,50) // works

focus on the last part that i wrote.

View 3 Replies View Related

C# :: Store Each Char Of A String Into Byte-array?

Apr 25, 2014

I am trying to store each char of a string(string a ="1100") into a byteArray ( byte[] byteArray = new byte[4]. its not showing any error but its storing like below:

byteArray[0] = 49
byteArray[1] = 49
byteArray[2] = 48
byteArray[3] = 48

and what i want is

byteArray[0] = 1
byteArray[1] = 1
byteArray[2] = 0
byteArray[3] = 0

I don't know why but its replacing 1 with 49 and 0 with 48.what am I doing wrong or how to do this?

my code is as below

byte[] byteArray = new byte[4];)/>
int binArrayAdd = 0;
string a ="1100";
foreach (char Character in a)
{
byteArray [binArrayAdd] = Convert.ToByte(Character);
binArrayAdd++;
}

View 4 Replies View Related

C Sharp :: How To Extract A String From Byte Array

Feb 11, 2014

i need to search for a keyword in a binary(.raw)file and have to extract the characters(until a '&' character is found)that immediately following the keyword .

View 1 Replies View Related

C++ :: Storing A String In Byte-array Form?

Jun 6, 2012

I am trying to use C# with C++, two different applications that work together.

In C# it is easy to get a byte array out of a string, by just using Encoding.Default.GetBytes(of-this-string);

I can pass bytes to my C++ program by just writing in the embedded resources. But this won't allow strings, as far as I know it can only be a byte array. C++ reads the embedded resources a LPBYTE.

So I try to send the string or message in byteform.

However the problem in C++ is that there is no Encoding.Default.GetString(xxx)

Would there be any other ways to send a message/sentence in bytearrayform and request it in C++ back to the original string?

View 14 Replies View Related

C# :: The Requested Operation Requires Elevation

Jul 28, 2014

This program is meant to present users with a list of rooms they then press the 'Select' button and it starts the relevant program for that room. However when running the program on Windows 8 it is giving an error that 'The requested operation requires elevation.'

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;

[code]....

P.s. It runs the programs as local administrator so that the user does not get prompted for UAC permission, as this is something the users find very annoying!

View 8 Replies View Related

C++ :: Application Has Requested The Runtime To Terminate It In Unusual Way

Jan 13, 2015

this application has requested the runtime to terminate it in an unusual way. contact the application support team for more information!!!

#include <cstdlib>
#include <iostream>
#include <fstream>
#include <string>
#include <stdlib.h>

[code].....

View 6 Replies View Related

C/C++ :: Linear Search Not Found Output

Jul 3, 2014

How to return a message saying that the value searched for is not found. We had to pull the data in from a .dat, i won't let me attach it as a .dat so I attached it as .txt. I know my it's sloppy. I usually clean up what I can once it is working properly.

#include <iostream>
#include <iomanip>
#include <fstream>
#include <string>
using namespace std;
int ccnt;
int size = 10;

[Code] ....

Attached File(s) : dat45.txt (273bytes)

View 3 Replies View Related

C/C++ :: Implement Breadth First Search Graph And Output Order Of Traversal

Mar 26, 2014

I'm new to program breadth first search and for my assignment we have to implement a breadth first search graph and output the order of the traversal. The problem is when I run my program I do not get any output from my traversal. All I get is "Breadth First Search Traversal starts at Vertex 2 and the order is: "

Here is my Queue class

//Declaration of node
struct node{
int info;
node *next;
};
//Defining Queue class
class Queue{

[Code] ....

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/C++ :: Converting 8-byte Integer To String Based Integer

Oct 15, 2014

Complete the function myitohex so that its converts 8-byte integer to string based hexadecimals.

Ex: printf("0x%s",myitohex(64,hex)); should printout "0x40" on the screen
char *myitohex(uint8_t i, char *result){
???
return result;
}

I wrote:

#include <stdio.h>
#include <stdint.h>
char *myitohex(uint8_t i, char *result){
*result = i + '0';

[Code] ....

0xp gets printed out which is wrong. I think *result = i + '0'; is wrong. What changes should i do on this row ?

View 4 Replies View Related

C/C++ :: Input Lowercase String / Output Uppercase String

Dec 3, 2014

write a program that prompts the user to input a string and outputs the string in uppercase letters. (Use a character array to store the string.) Does this follow the criteria? This program is very similar to one I found on these forums but I have one problem, it outputs everything backwards! EX: dogs will output to SGOD. What I need to do to make it output correctly, I think it may have to do with getline?

#include <iostream>
#include <cctype>
#include <cstring>
using namespace std;
int main() {
char let[100];
cout << "Enter what you would like to be UPPERCASE: ";

[Code] ....

View 2 Replies View Related

C :: Search File For String

Aug 22, 2014

I should state that I am recently new to C programming. I have dabbled with Python in the past, but nothing formal. I am taking a C programming class, but it is an introductory course. As such, the instructor is moving extremely slow through the material.

With this program, I am trying to search a given text file (line-by-line) for user-submitted data. I then want to be able to store which line that data was found on. The program runs, but it always results in "Sorry, couldn't find a match." Even if it shouldn't.

Code:

#include <stdio.h>
#include <conio.h>
#include <string.h>
#include <stdlib.h>
}

[code]...

I should probably explain my overall goal with this program.I would like to write a program that will calculate the molecular weight of a compound. I expect the user entered molecular compound to be something like this: CH3COOH (An equivalent entry could be C2H4O2)Also, it needs to be case sensitive because the chemical formulas are case sensitive.

The output will be "The molecular weight of CH3COOH is xxx.xxxxx grams".I have two text files as well. One contains a list of all chemical symbols, and the second is a list of all atomic weights in the same order as the first. I want to place the user inputted data into an array, then search for each element of that array in the chemical symbol text file. It will show which line it was found on, then I can use that line to grab the atomic weight from the second text file.

View 5 Replies View Related

C :: Search Chain In String

Mar 23, 2013

i have a work to do that consists on a given char pointer to a chain and a also given char pointer to a string. i have to search that chain in the string, and return the position where the beginning of the two it's equal. but only if they are equal.

example: string is "abcd" and the chain is "bc". want to find the chain, and if it exists, the position return will be 2. in the work it says that we should use sprintf() too. here is my code, which is incomplet yet.

Code:

char* pos(char* C,char* S){
char *str = S;
char *chain = C;
int i, j, temp;
int lengthStr = strlength(C);
int lengthChain = strlength(S);
}

[code]....

my doubt is how to use sprintf() and where. if i have to use malloc() and free(),

other examples:
pos(AGA,CTGCA)
return:
0

pos(AGA, ATAGATA)
return:
3

pos(AGA AGATAGA)
return
1 5

View 6 Replies View Related

C :: Binary Search With String Algorithm

Oct 3, 2013

I'm trying to use the biSearch function to search for a keyword in the dictionary.

Code:
int biSearch(Dict DictEntries[MAXENTRIES],int start, int finish,char *keyword) {
int mid = (start+finish)/2;
int index = strcmp(DictEntries[mid].key,keyword);
printf("%s=%s
",DictEntries[mid].key,keyword);

[Code] ....

View 4 Replies View Related

C++ :: BAC Calculator - String Stream Search

May 14, 2013

I am working on a project which is a fairly simply BAC calculator. I am attempting to grab data from a text file, which contains state abbreviation, maximum BAC before aggravated, and minimum license suspension. The text file looks like

#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <stdio.h>
#include <ctype.h>
#include <iomanip>
#include <algorithm>
#include <cstdlib>
#include <sstream>
using namespace std;

float MALE_RATE = 0.68, FEMALE_RATE = 0.55, LEGAL_LIMIT = 0.08;
//percent of body weight which holds alcohol

[Code] ....

The code I am struggling with is the getline and stringstream which is near the bottom.

The output I am getting is

The maximum BAC before aggrevated DUI in AL is .15
The minimum penalty in AL is 90 day suspension of license

I get that for every state I type. I know it is reading the first line, but something in my code does not allow it to read the other lines

View 1 Replies View Related

C++ :: How To Search For A Specific Character In A String

Feb 4, 2015

i'm doing a validation exercise program. Just a question, how do i search an inputted string for a certain character?

For example:

Hello.World

I wanna determine and find out the where the '.' sign is.

I'm doing an if-else conditions, i need to determine where the character is located and make sure it doesn't repeat.

View 4 Replies View Related

C# :: Search / Highlight And Replace String

Jan 11, 2014

I am a beginner of c#.. i have try to made a windows notepad and face some issues. I want to add find string from open file... and also want to replace it with a new string... Is there any simple and easy solution to this problem??

View 7 Replies View Related

C :: Strstr Function / Search And Replacing New String

Sep 23, 2013

Code:

#include<stdio.h>
#include<string.h>
#define MAX 25
int main(void)
{
int ch;

[Code]....

i think that cause this program to be error.because when i using the reference from internet, the program was executed for sure.This code what i mean

Code:
#include <stdio.h>
#include <string.h>
#define MAX 10
int main () {
int ch;
char str[] ="This is a simple string";
char str1[MAX];
char str2[MAX];

[Code]....

and rather than that i didnt have anymore idea to make that replacing string.

View 6 Replies View Related

C++ :: Binary Search Of String In Array Of Objects

Oct 20, 2013

I need to search for a string in an array of objects, this is what I have but it does not seem to work, it always gives me the second string in the array instead of the one that i search for.

void binarySearch(Student S[], string name) {
int first = 0;
int last = 9;
int middle;
int position = -1;
bool found = false;

[Code]...

View 3 Replies View Related

C/C++ :: Strrchr Function - Search For A String From The Reverse

Feb 27, 2014

I understand that the strrchr function is supposed to search for a string from the reverse. Unfortunately, mine isn't doing that.

#include <stdio.h>
#include <conio.h>
int main() {
char userinput[100] = "null";
char searchchar;
char *s;
char try_Again;

[Code] ....

View 5 Replies View Related

C :: Linear Search Function Accessing String In A Struct?

Apr 5, 2013

I currently have a file which allows inputs to record different transistor types. I then have the task of accessing this structure, find a certain manufacturer ID, and print the information about this particular transistor.

My problem is accessing the array to search through.

Here is my code:

Code:
#include "stdio.h"
const int IDLEN=30; //All constant values defined
const int POLARITYLEN=3;
const int MAXSTOCKITEMS=10;
//First structure defined
struct TransistorRec {

[Code]......

The errors I am currently getting are on line 54 'expected primary-expression before "struct"' and on line 60 ' 'maunfacturersID' undeclared'

View 11 Replies View Related

C++ :: Search Dynamic Array For A String And Return Indices

Feb 20, 2015

I need it to search a dynamic array which I build from an input file. When it finds the user-input string, I want it to store the line number, and continue searching, and record all lines that contain the user-input string.

Here is a link to my complete main.cpp, header file, and implementation file. The function I am having trouble with is "Bagger::lineSearch"

[URL] ....

View 2 Replies View Related

C++ :: Search In A Vector Array From User Input String?

Sep 30, 2013

How would you search in a vector array from a user input string?

ex: user input : "Hello"

output: search vector array and find the line that has the string "Hello" and output the array "Hello" is on?

View 1 Replies View Related

C++ ::  String Output Without Linebreak?

Mar 10, 2013

I want to process data (using fstream) and print out the progress. This doesn't work with cout <<, only with puts, but this causes a line-break but I want a progress bar like this : [=====================].

I've already searched for an hour in the reference and with google and I dont manage to put a string without a linebreak:

while (ein.good()) // loop while extraction from file is possible
{
c = ein.get(); // get character from file
if (ein.good()){

[Code]....

how to do it without the linebreaks..

View 2 Replies View Related

C++ :: Capture Output From EXE In A String

Mar 7, 2014

I am writing a small editor for RSL coding, and ive got an external program "3Delight" to compile the code.

Now i want the output from that exe to be captured in a string once the compilation is comlete, but all of the methods ive found online dont seem to work for me. Ive tried using _popen which works if i run a normal command like "dir", but not with the exe.

This is the function ive been using that works with the normal commands

std::string exec(const char* cmd) {
FILE* pipe = _popen(cmd, "r");
if (!pipe) return "ERROR";
char buffer[128];
std::string result = "";

[Code] .....

and this is how i was calling it, but it just returned an empty string, even though the exe printed "Compilation successful"

exec("""%DELIGHT%/bin/shaderdl" "E:/RenderManShaders/TestArea/Source/basicDiffuse.sl"")

View 3 Replies View Related







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