I've been trying to get this to work. It complies but my char array won't display anything. 'cipher2.in' contains this: 3 L E ABCDEFGHIJKLMNOPQRSTUVWXYZ Output: Cipher Code: Cipher Text: ABCDEFGHIJKLMNOPQRSTUVWXYZ Cipher Key: 3 [CODE]import java.util.*; import java.io.*; public class Test2 { public static void main (String[] args) throws IOException { Scanner input = new Scanner(new FileReader("cipher2.in")); String cipherText; String cipherDirection; String cipherType; int cipherKey; cipherKey = input.nextInt(); cipherDirection = input.next(); cipherType = input.next(); cipherText = input.next(); encrypt(cipherText, cipherKey); } public static void encrypt(String cipherText, int cipherKey) { int letterPosition; int arrayPosition; char[] cipherCode = new char[cipherText.length()]; letterPosition = cipherKey; for …

Member Avatar
Member Avatar
+0 forum 2

so im trying to build a connect 4 gameboard using charecter arrays and it has to look like this O | O | O | O ------------- O | O | O | O ------------- O | O | O | O ------------- O | O | O | O Column: A B C D so far ive got everything working except for the barriers on the odd numbered lines, it just gives me gibberish for some reason [CODE]#include <iostream> #include <cstdlib> #include <cstring> #include <string> using namespace std; // ----------- Function definitions ------------- void setgameboard(char board[7][12]){ int i,j,k; for …

Member Avatar
Member Avatar
+0 forum 5

I need to write a loop to go through a string and retrieve alternate characters from index positions. Then append the characters to another string and then print (eg. "pleasehelp" = "peshl") I have hit a wall and lack any sort of know how to push through... what have I got myself into? All I have is below. string sentence = "please help"; char[] charSentence = sentence.toCharArray(); for (sentence);

Member Avatar
Member Avatar
+0 forum 1

Hey guys, so I'm trying to write a little program that will put together any number of strings passed to it into a single string and then print out that string backwards. I think I have everything correct but I keep getting a "Segmentation fault (core dumped)" error after compiling and running. So far the output I get looks like this if I enter "Hello" and "World" for my two strings: [CODE]argc = 3 argv[1] = Hello argv[2] = World len = 12 string = ÿ9 string = ÿ9Hello World Segmentation fault (core dumped)[/CODE] Also, how can I fix that …

Member Avatar
Member Avatar
+0 forum 10

Hello All, I am not sure why my algorithm is not working for this problem. I need to store space separated arguments in an array char* argBuffer[], so I can later make some system calls . The problem is that the last argument is writes over all indexes of the array. I'm newer to C programming. [CODE] #include <stdio.h> #include <string.h> #include <unistd.h> #include <stdlib.h> int main(){ char line[50]; int count = 0; char c; //get user input stop when enter is pressed while((c = getchar() )!= '\n'){ line[count] = c; count++; } line[count] = '\0'; printf("you entered: %s\n",line); char* …

Member Avatar
Member Avatar
+0 forum 3

I am making a program for my class where I handle equation problems such as: 2a-3b+5c=10 3a-2b-3c=-5 where the answer would be: 5a-5b+2c=5 This is what I have so far. It still isn't perfect cause I still haven't figured out the "=" part. I do have it performing the math though. But the answers are coming as: 5a5b5c-5a5b5c+2a2b2c. I don't understand why. Any help would be much appreciated.[code]#include <iostream> #include <iomanip> #include <cstring> using namespace std; // Declarations const int length=26; int num_var, i,j; char variable_array [length]; int equ_1 [length], equ_2 [length]; int main() { cout<< "How many variables are …

Member Avatar
Member Avatar
+0 forum 3

Hello. I would very much appreciate if someone would aid me with a hint. My problem is as follows : read two arrays of chars and merge them into a third array like so : ARR1 :123abc ARR2: rt678iogl ARR3:1r2t36a7b8ciogl The problem must be solved without pointers and string.h Basically Im stuck at the the above merging procedure. I myself am not a very experienced programmer as you can notice, but a hint in the right direction would be very much appreciated. No code please . Thank you very much !

Member Avatar
Member Avatar
+0 forum 7

the code is: [CODE] slen=strlen(str); for(count=0;count<=slen;count++) { flag=0; if((int)str[count]!=32) { for(count2=count+1;count2<=slen;count2++) { if(str[count]==str[count2]) { flag=1; break; } } if(flag==0) { ar[ar_count]=str[count]; ar_count++; } } }[/CODE] at line 5 the != operator working fine but when i put [ICODE]if(((int)str[count]>=65 && (int)str[count]<=90) || ((int)str[count]>=97 && (int)str[count]<=122))[/ICODE] it's not working.. if you've some time to spare and want to know more about this program then read the following: the question is [URL="http://www.daniweb.com/forums/thread111702.html"]here[/URL]. the guy is answered the solution there, but since i don't know anything about pointer or file handeling i didn't understand a thing there...:sad: so here's my program: [CODE]#include <stdio.h> #include …

Member Avatar
Member Avatar
+0 forum 15

Hi, first of all I would like to thank you for taking the time to look at my problem. I'm trying to input to a multidimensional character array. The error occurs on the second array. I tried to understand the problem by varying my input, but it always occurs on the second array. It prompts for a second entry though. If you set the size as one and enter an applicable character array it returns to main and outputs that array. I've tried to Google an answer but I couldn't identify my error. They always showed integer arrays. I think …

Member Avatar
Member Avatar
+0 forum 2

The End.