I'm looking for a algorithm to search portions of string that have the same caracter. The only possible values are: a,n and g
Char index: 0 1 2 3 4 5 6 7 8 9 RESULT
------------------------------------------
Example 1: a g g g a a 0,4
Example 2: g g g a n n a 0,3
Example 3: a g g g g g g a 0,7
Example 4: g g g g g g g 0,6
Example 5: g g a a g a a a g 0,2,3,5,7,8
I'm trying to right the function that puts the correct letters in the right positons being reported from my previous compareletter function for my game of hang man and its not updating the word in progress array. Here's my compare letter function that's working correctly:
Code: //function that returns the index of the letter that the user has guessed or Code: //-1 if the letter isn't in the word int CompareLetter(char array[], char guess, int numLetters) { int i;
[Code....
However, this isn't changing any of the position of the asterisks in the word in progress array positions 0-3.
I'm working on a homework project, and it requires me to read in a file of chars into an array, and then do stuff with that array.
Anyways, I have the first part written, where I'm just trying to read in my data.txt file, and I thought I had it written well. It compiles, but then it seg faults, and I'm not sure why. I used calloc for the array, but maybe I misused it? Or is it in my EOF statement? I'm still not sure if that's coded correctly. I need to get past this so I can start testing the other parts of my code.
Code: #include <stdio.h> #include <stdlib.h>
int main(int argc, char* argv[] ) { /* Local Declarations*/ int i; int *ptr; char tempc;
I am trying to convert some chars to UTF-8 strings...
Example:
std::string gethex(char c) { /* EXAMPLE if (c == 'é') return "%c3%a9"; I need a function that converts chars like "á, é, í, ã" to UTF-8 hexadecimal strings... */ }
[Code] .....
[URL] .... does it. Choose UTF-8, type some character and click 'Url Encode'.
I'm writing a school assignment that writes/reads user input into and out of a binary file.
I've gotten the write part to work, but now I need to be able to read that file back in and display it as a string.
I think I should be using fread() and read my file into an array of int's right? But when I try printing out that array I get a whole bunch of numbers that don't match the hex code in my file.
How do I read in a binary file and print it out as a string?
(below) on a website which is used for printing the characters as the keys on keyboard are hit i-e without hitting the ENTER key. This method is used in a while loop like this
Code: while ((c = win_getch()) != 13) {}
I wanted to know why is the character compared to
Code: 13 i-e Code: if((c = win_getch()) != 13) then do something
Code: /** * This function will simulate the getch() function from conio.h. * Note that this does not work for special keys like F1-F12, arrow keys, * even the ESC key does not seem to work with this function. * @return TCHAR read from input buffer. */ TCHAR win_getch() { DWORD mode; TCHAR theChar = 0;
As a part of a program I am supposed to write, I would like to receive a string from the user (for example: "Hi my name is Joe").
obviously, the string is inserted to an array of chars (arr[0]='H', arr[1]='i', arr[2]=' ',... and so on).
What I would like to do, is to put each word separately in each array cell (for example arr[0]='Hi', arr[1]="my"..., and so on). How can I do this? (I can not use any functions, unless I write them myself).
How to give input with text for this function.i already create function for this but i dn't know give input as non ASCII value(0-32) that Cobain with string or simple text.
For some reason my code is not couting right. My function is supposed to decipher some code that if it has multiple same chars then it drops one. Example aabbyfkk --------> abyfk. But it couts abyffkk . For some reason it is not getting rid of the extra f and k chars.
string decrypt (string encrypted) { string deleted, tmp; int i, pos, n, j=0, z; tmp=encrypted;
I was supposed to sort out an input, getting rid of chars and only using the numbers. So 5a6g7we87hj9 would become 567879. I might be wrong in some way, but I used
I am trying to make a for loop that will print out chars in an array while using a #define before main. My problem is that each name has a different amount of chars in it. How do you account for that when you are trying to define a size? For example, I am playing around with the numbers and I just put 7 in for size:
That code should make the size of the pointer (how many chars it can store) bigger but when i run it it show always 3 char positions while it should show N*M.
Code: #include <stdio.h>#include <stdlib.h> int main(void) { int M, N, P, i; scanf ("%d %d", &M, &N); P = M * N; char *c = malloc(P * sizeof(char));
Write a program that reads a group of chars till $. Then, compute # of vowels, # of digits, # of word and # of special chars. Your program should display all required results.
How do I detect garbage chars in a CString. Actually I'm reading some data from COM port. In some certain condition it will give some garbage as a version no. Now I need to show _T("N/A") in case of there is any garbage.
My solution is to check for a Valid char or integer. If found its correct else Garbage.
I'm supposed to create a program that will find the min/max values of two ints, doubles, and chars, It's not completely done but here's what I have so far.
It's giving me an Error 1 error LNK2019: unresolved external symbol "public: __thiscall MinMax<int>::MinMax<int>(int,int)" (??0?$MinMax@H@@QAE@HH@Z) referenced in function _mainC:UsersDerickDesktopCiss243Week3 Assignment2Week3 Assignment2Main.objWeek3 Assignment2
Header file #ifndef MINMAX_H #define MINMAX_H #include <iostream> using namespace std; template <class T> class MinMax
[Code] ....
I don't know why the site is adding in extra bits of code like /> in certain areas, it's not there when I paste it in and it's not in my code ....
I'm trying to write a program which prints a table of ASCII chars, I'm not really done with my thoughts on it but I already ran into the following error:
Error: cannot initialize a variable of type 'char' with an rvalue of type 'char (*)[16]'
Here's my code so far:
# include <iostream> using namespace std; int main() { char asciiTable = new char[8][16]; int nextSign = 0;
I am trying to write a function to save the state of a tic tac toe game. It seems to be working well except the loop to read the chars in from a .txt file is running 18 times instead of 9 and thus overwriting the array with blank boxes. The code below is the part of the function I am having an issue with. Counter is being increased every time the second for loop runs which should be 9 times. However, it is apparently running 18 times with the first 9 runs filling newBoard correctly and the second 9 times overwriting it with boxes. how to fix it?
ifstream inputFile("file.txt"); char newBoard[3][3]; char a; int counter = 0; while(counter<=9) { for(int r = 0; r<3; r++)