prints a single byte after character typing

I am receiving some data from a socket. After that, I want to print a single byte in the received char array. Below is the code that I used: char buf[100]; int i = 0; while (1) { rc = recv(socket_fd, buf, sizeof(buf), 0); if (rc > 0) { printf("Pos

Read the char table line in matlab

What I have I've a char array, defined by doing an strcat between two char arrays like this: coeficientes = strcat(coef_bin, coef_bin_comp) Then, I want to read each row and convert them to hex. I'm doing it like: for k=1:11 coef_binario = coeficient

How to convert extracted LSB data to text or binary to text

UPDATE*********************** For reference I included the program I made for opening a PPM image - embedding a message into the image and then saving out a new image with the embedded text. With the function below I'm hoping to extra that message, (

System string ^ Adding characters to stack (Visual C ++)

I'm trying to get characters from a String^ to put into a stack to use later, but when I check what actually gets put in it always has a number in front of it which messes up using it later (e.g. If I try to get a "-" character from within my st

Find the word in the C # string

This question already has an answer here: Get string between two strings in a string 15 answers I have a string that contains something like this "'asd asd asd / * ... asd ' asd..." I just want to retrieve only the value that starts from ' and e

Why can not I use all the char [] in while?

In Python, I can do: str = "abcd" while(str): print str Although it's not very useful (iterating over the elements in the string is usually what's needed), the fact that it's possible makes me wonder why the equivalent in C is not, So: char str[

Put only a certain number of lines in a char array

I have a file with 2939 lines, and I am trying to save the five lines together in one index of a 2D char array. So, char [][] myArray; myArray[0] = {} //<--char array of first five lines myArray[1]= //char array of next five lines the way I am implem

Assigning and comparing characters to integers

I have a char array: char arr[5]; Say I assign it the values: arr[0] = 1; arr[1] = 2; arr[2] = 3; arr[3] = 4; arr[4] = 5; When I print using: printf("%c\n", arr[0]) nothing is printed out (only the newline). When I print using: printf("%d\n

See if a string contains a character and write it

I'm a beginner at this and hoping someone can help me. What I am trying do is check if the character in char b exists in string s. If it exists, it should write the letter out to the char array at the right index number. If not, then it should write

take the tank entrance and store it in a painting

I want to take n number of inputs and save it in the arrays c[] and p[] and later use them... I have currently written this,but i'm not getting desired output #include<stdio.h> #include<stdlib.h> int main() { int n,t,i,j,size=0; char s[100000]

Why does scanf grab \ n?

I'm writing a basic C program that will convert either Celsius or Fahrenheit to the other. I have a scanf statement where the user enters the temperature they want to convert, and then a printf statement asking for whether that temperature was in c o

Read from file using char * as parameter

I am using a function that uses a char* parameter; i am reading from a file for input. Here is my code: std::ifstream infile("file.txt"); std::string line; while(std::getline(infile,line)){ if(pass(line.c_str())==0) cout<<"this is cor

2nd call to strtok () returns null

I'm at the top of a while loop in the client file for a client/server communication. The client gets user input (input) and I need to strtok it into cmd and cmd2 for my ifs to work. Say the user puts in "get lname" (this is a good command for th

C: Loss of the tank contents ** after the end of the function

This question already has an answer here: Using realloc inside a function [duplicate] 2 answers I have a problem I can't solve. I split a string in substrings and put these substrings in an array. Everything goes fine until the search function ends.

Why char '\ & ldquo;' same as char ''?

quick question. Why are both lines below valid? char x = '\"'; char y = '"'; If " is a special character, shouldn't the second line be marked as incorrect?If " is a special character, shouldn't the second line be marked as incorrect? N

Convert an int to a character in C?

I'm trying to add an int to a char array. My (broken) code is as follows, string[i] = (char) number; with i being some int index of the array and number is some integer number. Actually, while typing this out I noticed another problem that would occu

Java how to replace a char to an index set with a string

Hi I need to be able to replace one character with a string at a set index. Example: "hello ? would you like a ? from ?" this is the method I would like to use: query.bindValue(0,"Mr Boo"); query.bindValue(1,"cake"); query.bi

difference between array and string array in cplusplus

This question already has an answer here: What is the difference between a Char Array and a String? 9 answers I want to know the difference between character array and string in c++. Can any one answer to this?? Please, Thanks Vishnukumarstring is a

How to convert a binary! to a chariot! in Rebol 2?

It's easy to convert a char to a binary: >> c: #"^(52)" == #"R" >> type? c == char! >> b: to-binary c == #{52} But what if I want to go the other way? >> c: to-char b ** Script Error: Invalid argument: #{52} **

java string index out of bounds

I have gone over and over this code and can't see where this is happening it doesn't happen every time it only happens if I run through post twice but I have tried getting rid of each of these in turn by commenting them out and that still gives the e

const char ** name VS char * name []

I know this topic was already discussed several times and I think I basically know the difference between arrays and pointer but I am interested in how arrays are exactly stored in mem. for example: const char **name = {{'a',0},{'b',0},{'c',0},0}; pr

getline () jumping first even after clear ()

So I have a function that keeps skipping over the first getline and straight to the second one. I tried to clear the buffer but still no luck, what's going on? void getData(char* strA, char* strB) { cout << "Enter String 1: "; // Shows thi

How to return a & ldquo; Java Java prim & rdquo; from Scala?

If I write: def getShort(b: Array[Byte]): Short in Scala, I get a primitive short in Java, which is fine. But if I write: def getChar(b: Array[Byte]): Char I get a scala.Char object, which is NOT fine. And if I write: def getChar(b: Array[Byte]): Cha

Upset memory

I am puzzled by this response.Can anyone help me on this and point out where I am making a mistake? The output at codepad is "memory clobbered before allocated block" #include <stdio.h> #include <stdlib.h> #include <string.h> i