Hi all, I was wondering how to access individual elements in the below case: char *three=(char*){'2','5','8'}; If the assignment were like this: char *three="258"; it can be accessed with three[0],three[1].....etc. How to access in the first case?

Member Avatar
Member Avatar
+0 forum 1

Hi. I'm using 3 classes: the Character class, the Scanner class, and the Test class. This is the Character class: public class Character { private char cargo = '\u0007'; private String sourceText = ""; private int sourceIndex = 0; private int lineIndex = 0; private int columnIndex = 0; public Character(String sourceText, char cargo, int sourceIndex, int lineIndex, int columnIndex) { this.sourceText = sourceText; this.cargo = cargo; this.sourceIndex = sourceIndex; this.lineIndex = lineIndex; this.columnIndex = columnIndex; } /*****************************************************************************************/ /* Returns the String representation of the Character object */ /*****************************************************************************************/ @Override public String toString() { switch (cargo) { case ' ': …

Member Avatar
Member Avatar
+0 forum 2

Good day everyone! I have the codes for such a problem where, to create a program that counts how many times the second string appears on the first string. Here it is: #include <iostream> #include <conio.h> using namespace std; int main () { char first [100], second; int count; cout <<"Enter 1st String: "; cin.get (first, 100); cout <<"Enter 2nd String: "; cin >> second; for (int i = 0; i < strlen (first); i++) { if (tolower(first[i]) == tolower(second)) { count++; } } cout << "THE STRING " << "'" << second << "'" << " appeared " << …

Member Avatar
Member Avatar
+0 forum 8

Hello all!Im trying to write a program that accepts a string from users and then converts each character in the string to its corresponding 8-bit binary code and store it for further manipulation on obtained bit. I have the following code but it is not executing as expected : #include <stdio.h> #include <stdlib.h> #include <string.h> int xstrlen (char *s) //for later use { int length = 0 ; while ( *s != '\0' ) { length++ ; s++ ; } return ( length ) ; } char* showbits(int n) //to print binary equivalent { int i, k, andmask ; char* …

Member Avatar
Member Avatar
+0 forum 2

Hi, Im making a simple program which converts a encrypted text file the upload it to sql CE. This is time in and out logs of every employee. The date is extracted from a machine and downloaded as encrypted file. We managed to decrypt it by getting the equivalent value of each character. I need to decrypt this file then save it to database (sql server 2008 r2) Downloaded file looks like this, in plain text: ±²®ªÇª®°­°®­°®¯±ª®·¸²®¸±²B ´µ³ªÇª®°­°®­°®¯±ª®·¸²±¸³®N ´µ³ªÍª®°­°¯­°®¯±ª¯·¸®°¸²²T ±²®ªÍª®°­°¯­°®¯±ª°®¸®®¸°®9 ±¯´ªÍª®°­°¯­°®¯±ª°®¸®®¸±²A ´µ³ªÇª®°­°°­°®¯±ª®·¸±¶¸±´X ±¯´ªÇª®°­°°­°®¯±ª¯®¸²¯¸²´C ±²®ªÇª®°­°°­°®¯±ª¯®¸²±¸°µA ´µ³ªÍª®°­°°­°®¯±ª¯·¸±¶¸±²] ´µ³ªÇª®°­°³­°®¯±ª®·¸³¯¸²µX My code for now in uploading: (I used openfiledialog object to open the file) …

Member Avatar
Member Avatar
+0 forum 9

I need a way to print(and later on compare - but for now just print) characters 2 by 2 as in: I have a string of 1F190307091810 and I have to print out: 1F 19 03 04 09 18 10. I need this for Baudot code(I have segments of code given to me and I have to compare letters and numbers - together, two by two) If you don't understand something please ask(I know I explain this in a weird way).

Member Avatar
Member Avatar
+0 forum 8

Hi, I start with code: int main() { Dict d; int n; std::cin >> n; char word[100]; for (int i = 0; i < n; i++) { std::cin >> word; d.addWord(word); } d.addWord("dog"); d.addWord("drog"); .... return 0; } I don't know why when I call method addWord manually, i.e. calls d.addWord("dog") or d.addWord("drog") it works good. But when I try to input data during program work (std::cin>>word) it stores only my last put word. For example if i try to input words: car, train, bus and later words dog and drog are added, program after taking some operations, returns vector …

Member Avatar
Member Avatar
+0 forum 3

Hello. can You help me with my program. I have to enter two lines from the keyboard, and in the third line program must write the same words from the first two lines. I also can use standart Pascal functions. But in this code I use my own function and I cannot find a mistake. program six; function Slovo(s:string;n:integer):string; const lim =[' ',',','!']; var ss:string; k,c,i:integer; begin ss:=''; c:=1; k:=1; while k<=length(s) do begin while not(s[k] in lim) and (k<=length(s)) do begin if c=n then ss:=ss+s[k]; inc (k); end; inc ( c ); while (s[k] in lim) and (k<=length(s)) do …

Member Avatar
Member Avatar
+0 forum 1

What's the difference between: int once; cout << "ok"; and this: char twice; cout << "ok"; Is the output for the first one just ok and the second one ok ok ?

Member Avatar
Member Avatar
+0 forum 10

i have a .csv file contain some name as below: William Shakespeare charlie chaplin david Copperfield and i'm supposed to write a java program that will turn the input above into the output below: WS cc dC but i still couldn't get the output that i want, i wanna ask is there anything wrong with my code below? import java.io.BufferedReader; import java.io.FileNotFoundException; import java.io.FileReader; import java.io.IOException; import java.util.*; import java.io.*; public class tryname { public static void main(String[] args) { tryname obj = new tryname(); obj.run(); } public void run() { BufferedReader reader = null; char tempname; //int point =0; …

Member Avatar
Member Avatar
+0 forum 15

Hi, Is there any java functions are availble to find mostly repeated characters in string ? Thanks

Member Avatar
Member Avatar
+0 forum 2

Hi! I have just started on c++ and have encountered Expression: (unsigned)(c+1) <=256 Error when I am trying to run the program. The program is suppose to generate an array of letters (lowercase and uppercase) of size from 15 to 25. After the generation, using ONLY one while-loop, try to move all lowercase letters to the left of the array and all the uppercase letters to the right of the array. It have to contain the following criterias (a) A function to construct the array (b) A function to print out the array elements (c) A function to swap two …

Member Avatar
Member Avatar
+0 forum 4

I'm trying to implement a hangman game using linked lists but not getting anywhere. I want guessed characters to be inserted in a Linked list of chars at a position that corresponds to the character's position in the word they are trying to guess.(See example at bottom.) For some reason my play() method doesn't do what it's supposed to do. 1. I have a gameLinkedList class that takes in a word; creates a charNode reference (character node) and a LinkedList of charNodes with their info set to the '_' character. the size of the linked list is equal to the …

Member Avatar
Member Avatar
+0 forum 1

Just started learning c++ and ive got a bit stuck :L Im making a console application that injects a file into a process. The file name and process name are both specified at the start of the code using char FileToInject[] = "File_Name.xxx"; char ProcessName[] = "Process_Name.exe"; The console works fine, however the process name and file name are now fixed once ive compiled the console, and I am unable to change the file/process later on. What I would like to do is have the console ask for file name, and the process name, so I dont need to create …

Member Avatar
Member Avatar
+0 forum 2

I don't know what's wrong but the succeeding strings are not properly read by fgets. else { initArray(word1); //first string fgets(word1, 29, fileIn); printf("word1: %s\n", word1); len = strlen(word1); if(word1[len-1] == '\n') word1[len-1] = '\0'; while(!feof(fileIn)) { //succeeding strings in next line initArray(word1); fgets(word1, 30, fileIn); printf("word1: %s\n", word1); len = strlen(word1); if(word1[len-1] == '\n') word1[strlen(word1)-1] = '\0'; fgetc(fileIn); } fclose(fileIn); } } texts: ABCD asnjf fkj read: ABCD snjf kj Can you give me an idea what's wrong?

Member Avatar
Member Avatar
+0 forum 4

Hi, I've been testing about converting infix to postfix expression. I've made the code and it compiles. My problem is it stops working when I run it. This involves the use of stack and arrays. I just call the method polish to get the strings infix and postfix, and to run the other methods, like findRank to know if it is a well formed postfix exp'n and evaluate it in method evaluate(). Please give me some ideas on how to fix this. This is the code... /* From Infix Notation to Postfix form, Knowing if it is Well-Formed, and Evaluation …

Member Avatar
Member Avatar
+0 forum 3

I am trying to make a program that generates source code for a much larger program for simple reversal encryption. I don't know what I am doing wrong. Here is my code so far: #include<stdio.h> int main() { FILE *fp; fp=fopen("d:\\crypt.h", "w"); fprintf(fp, "char out[8];char cur[8]; char con[255,255,255,255,255,255,255,255];/n if cur==con out==0,0,0,0,0,0,0,0;/n while(cur <= con) /n con=con-1/n if cur>=con out=out+1; "); return 0; } please help, thank you

Member Avatar
Member Avatar
+0 forum 2

okay i have a file with data orgainzed like this in a dat file to be read: apple.0.0.end. and i want it to be read by char until it sees "." then print that, then read again repeated until the end of the line. so i can show the data like this: name? : apple noun? (0 for yes; 1 for no): 0 eatable? (0 for yes; 1 for no): 0 can this be done? how? and explain like im 5 years old for future reference.

Member Avatar
Member Avatar
+0 forum 2

What's the difference between char and varchar in phpmyadmin ? I am trying to decide whether to use char or varchar for name for example.

Member Avatar
Member Avatar
+0 forum 5

I have a 8 digit number that is an int, and would like to know if there is an equivalent method that i could use on it like charAt(). or a way to take just one digit out so that it is still an int value and be able to add, multi, etc.

Member Avatar
Member Avatar
+0 forum 2

In the following piece of code i am trying to enter a 8 digit binary number then manipulate each digit seperatly. import java.util.Scanner; public class binCoverstion2{ private static Scanner kbd = new Scanner(System.in); public static void main (String[] args){ int bit0, bit1, bit2, bit3, bit4, bit5, bit6, bit7, decNumber; System.out.println("Enter a 8 digit binary number then hit enter."); String binaryNum = kbd.nextLine(); bit0 = binaryNum.charAt(0); System.out.println(bit0); The output of bit0 is just to see what the value was set too. the input i gave it was 10011001, but bit0 was set to 49. Why?

Member Avatar
Member Avatar
+0 forum 1

i have a problem with how to use c programming keywords while doing programming can you post me some solutions with these keywords as with their uses and meanings.

Member Avatar
Member Avatar
+0 forum 7

Hi! what is wrong with the following function? void foo(*ptr){ char buff[127]; ctrcpy(*ptr,buff); } I know that it doesn't really do something... it's for information purpose only.... Thanx!!

Member Avatar
Member Avatar
+0 forum 7

I have a bit of a baffling problem! I'm writing a tag matcher in XML and whenever I run the below procedure, I get a garbage value after the name of every tag **except for the first one**. When I add the array text to the parameters list, the garbage value goes away (I had it there during initial debugging) even though it isn't actually referenced at any point in the procedure. Another thing, is that while reading a tag, it doesn't seem to want to recognize spaces. For example, <img src="img.png"/> reads as imgsrc="imgpng" instead of img, but only …

Member Avatar
Member Avatar
+0 forum 1

I have the following code.According to this the values of pointers p[0] and p[1] remains unchanged since the swap is made to local variables in swap function.Now my doubt is how can I swap the pointers p[0] and p[1] inside the function swap?? #include<stdio.h> int main() { char *p[2]={"hello","good morning"}; swap(p[0],p[1]); printf("%s %s",p[0],p[1]); return 0; } void swap(char *a,char *b) { char *t; t=a; a=b; b=t; }

Member Avatar
Member Avatar
-1 forum 1

I have to accept user input, a string, into a doubly linked list and print the output reversed and forward. My professor gave us the following program and told us to modify it. However, I cannot figure it out. /* Program to reverse a doubly linked list */ #include <stdio.h> #include <stdlib.h> /* a node of the doubly linked list */ struct node { int data; struct node *next; struct node *prev; }; /* Function to reverse a Doubly Linked List */ void reverse(struct node **head_ref) { struct node *temp = NULL; struct node *current = *head_ref; /* swap next …

Member Avatar
Member Avatar
+0 forum 1

i am trying to use recursion to find the occurence of a specific character in an array of characters public class CharacterCounter { public static void main(String [] args) { char test[] = {'a', 'b', 'a', 'c', 'd', 'a', 'e', 'a', 'f', 'g', 'h', 'a', 'i', 'a'}; char searchChar = 'a'; System.out.println(characterCounter(test, searchChar, test.length-1)); } private static int characterCounter(char[] t, char sc, int index) { int count = 0; if(t.length < 0) return count; else { if(t[index] == sc) return count++; else return characterCounter(t, sc,index-1); } } } any help or suggestions would be appreciated.. thanks

Member Avatar
Member Avatar
+0 forum 4

Hi I am trying to write a binary search function to search for a specific character in a character array sorted in ascending order. Whenever I run the code though nothing happens, there are no errors or anything, just nothing happpens until I terminate the program myself. Below is my code. static int binarySearch(char A[], char key) { int f= 0; int l= A.length; while(f < l) { int mid= (l-f)/2; int x= A[mid]; if (x == key) return mid; if (x < key) f= mid; else l= mid; } return f; } From what I understand a binary search …

Member Avatar
Member Avatar
+0 forum 2

Hey guys, I need a function that reads a text file and stores the character someway, (I am assuming a 2D Array would be best?) then a function that reads through the characters and if the char is something specific (like "X") then it would draw a square (QUAD) 10wx10h multiplied by the location. Example: XXXXXX X....X X....X X....X X....X XXXXXX Would draw: [][][][][][] [] [] [] [] [] [] [] [] [][][][][][] X is the square, and . is a space (Nothing there, it would be skipped) Im basically creating a map based on a text file. CODE SO …

Member Avatar
Member Avatar
+0 forum 7

Hi there, I have an array of unsigned chars SOURCE, i need to combine into DESTINATION, i want to turn: SOURCE[0] = 3 SOURCE[1] = 9 SOURCE[2] = ' ' SOURCE[3] = 0 SOURCE[4] = 4 SOURCE[5] = ' ' SOURCE[6] = 7 SOURCE[7] = d into DESTINATION[0] = 39 DESTINATION[1] = 04 DESTINATION[2] = 7d Any ideas Many Thanks

Member Avatar
Member Avatar
+0 forum 12

The End.