im stuck on a question from the book, java in 2 semesters chapter 7. 2a) write a program that asks the user to input a string, followed by a single character, and then tests whether the string starts with that character. [CODE]public class StringTest { public static void main(String[] args) { String s; char c; //input string System.out.println("please enter a string: "); s = EasyScanner.nextString(); //input char System.out.println("please enter a character: "); c = EasyScanner.nextChar(); //compare string and char if(s.charAt(0) == c){ System.out.println("string starts with the character entered"); } else{ System.out.println("string does not start with character entered"); } } }[/CODE] …

Member Avatar
Member Avatar
+0 forum 4

Hello, Is there any limitation for the length of array variables in C++? Can I specify the length as wanted or is there any limitation for the array length? What should be the array length, if the length is not known. wchar_t commandString[10000]; Cheers

Member Avatar
Member Avatar
+0 forum 6

Hello, I have 2 **wstring** variables: std:wstring first =L"Jose"; std:wstring second = L"James"; How can I combine these variables: first + second gives an error in Visual Studio. Cheers

Member Avatar
Member Avatar
+0 forum 3

Hy Guys,I Need Your Help Regarding This Question.. I run this Program on Dev c++ and Compiler did not Show Error but During INput I can not input Name and Address in both student class and School Class.. Sorry For bad English.. :) #include<iostream> #include<string.h> #include<fstream> using namespace std; class school{ char name[50],address[50]; int regdno,totalstudents; public: void input() { cout<<endl<<endl<<endl; cout<<"<<<<<<<<--------Input School Information--------->>>>>>>>>"; cout<<endl<<endl<<endl; cout<<"Enter Regd.No Of school : "; cin>>regdno; cout<<"Enter Name Of school : "; cin.getline(name,50); cout<<"Enter Address Of school : "; cin.getline(address,50); cout<<"Enter Total No.of Students in School : "; cin>>totalstudents; } void output() { cout<<endl<<endl<<endl; cout<<"<<<<<<<<--------School …

Member Avatar
Member Avatar
+0 forum 2

Hi, I hope you can help me out of this because i really dont understand how to fix this code anymore, i tried and tried and it don't work. When i debug this code in Microsoft Visual Express 2010, it says the following erros are: 1>------ Build started: Project: Adreesbook2, Configuration: Debug Win32 ------ 1> adressbook2.cpp 1>c:\users\twice\documents\visual studio 2010\projects\adreesbook2\adreesbook2\adressbook2.cpp(37): error C2297: '>>' : illegal, right operand has type 'Node *' 1>c:\users\twice\documents\visual studio 2010\projects\adreesbook2\adreesbook2\adressbook2.cpp(37): error C2446: '==' : no conversion from 'int' to 'Node *' 1>Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or function-style cast 1>c:\users\twice\documents\visual studio …

Member Avatar
Member Avatar
+0 forum 3

JAVA How to read in strings from a file convert to byte code (unicode) and save in array for hashing? how to use hashing (using list of strings) to find longest chain? (from text file dont print the output in a file just dislplay.)

Member Avatar
Member Avatar
-1 forum 1

Hello, i need help with my project. Im making a program that encrypts and decrypts the contents of a text file. I had to generate an 8 character key which is converted to ascii and then calculate the offset factor of the key that was generated (New every time program is run) next i converted the contents of the user specified text file to ascii characters and added them to the offset factor calculated earlier, I need some help with this part though, it prints the (so far) the encrypted text and then adds it to offset factor, but the …

Member Avatar
+0 forum 0

I know I should have try it first but I dont understand what is this asking about. My english is my very bad. Can you please telling in easy english. PLus this is very confusing. Please help me out Write a BNF grammar for the for statement of C. Assume <expression> and <statement> and <block> are defined elsewhere nonterminals (you dont' define them). Statement is a single statement, including control statements but excluding block, and block is some code with {} around. Do not use the extended BNF notation. For the above, write operational semantics. Design a regular language where …

Member Avatar
Member Avatar
+0 forum 4

A little experiment with custom sorting the result of a word frequency count using Google's Go language.

Member Avatar
Member Avatar
+2 forum 2

This time just a simple example of grading scores (0 - 100) with letters (A - F). Two approaches are presented, one using switch/case in an "on the fly" function, and the other uses the score as an index to a string of letters F through A.

Member Avatar
Member Avatar
+1 forum 1

hey guyss..!! I'm having some difficulties working with strings (cstyle, object oriented strings). as this is something new for me so I'm not exactly familiar with functions of strings aswell.. write now i have a question for which i was making a solution but the code is missing something please help me out. Question statement. "Write a program that reads a whole paragraph (you can do that with a little common sense) from the user. Now prompt the user enters a word to be searched. Your program should read the search word and search for all the occurrences of that …

Member Avatar
Member Avatar
+0 forum 4

Hello, I am currently using bound parameters in regards to user input on my form. I have read about escape strings also and thought of using both together. Is this possible and, importantly, is it necessary considering I am already using bound parameters? I would like to use both. Thank you in advance, Matthew

Member Avatar
Member Avatar
+0 forum 2

Hi Group, I attempting to save a file to a specific folder that is begins with the hotels property number. Currently I've manually listed the properties complete folder name in a text file. This is proving to be a management problem that needs to be fixed. The code I'm using to find and save the file looks like this: Using reader As New StreamReader("O:\IPSDATA\Property Folder Names.txt") While Not reader.EndOfStream Dim line As String = reader.ReadLine() If line.Contains(propertyNo2) Then hotelFolder = line Exit While End If End While End Using ' setting the path name to save the converted file fileSave …

Member Avatar
Member Avatar
+0 forum 2

Hello. I am beginning the process of coverting all of my MySQL to MySQLi. I have been doing much research on this but find it a bit confusing. I have two questions at this point regarding the matter: 1) What does it exactly mean to "escape" a string and where does the code for this go? I assume it goes on my page with my database login credentials. I found the following but find it somewhat hard to interpret: "We'll use the mysqli_real_escape_string() function. Since it needs a database connection, we'll go ahead and wrap it in its own function. …

Member Avatar
Member Avatar
+0 forum 1

Hi, thanks for any help in advance. I was hoping to get some guidance for getting started with connecting to an SQL database online. I'm writing an application in Win32 which needs to be able to read/write to a database. I have plenty of experience with C++, but almost no experience with networking. All I need to do is store a list of strings in a database online where they can be accessed and altered from any computer. I've tried getting started with MySQL but I'm not having much luck. I'm not even sure if SQL is the best option. …

Member Avatar
Member Avatar
+0 forum 3

This is Python 3.4.2 The documentation says that s2 = s1.strip('a') will strip out all the 'a' in s1. When I run it, only the leftmost character - and only if it is 'a' - is stripped. The default s2 = s1.strip() takes out all whitespace. PS: I understand that the chars in () are a list. This is from an IDLE shell: >>> s2 = 'qazxswedc'.rstrip('x') >>> s2 'qazxswedc' (Also with .lstrip('x') and .strip('x') ) Have I found the very last bug in Python?

Member Avatar
Member Avatar
+0 forum 4

So I'm trying to remove 2 brackets from lines I'm reading from a file. For some reason when I run my program the characters in between the delimeters is removed. for example `greetings pe()ple` would end up as `greetings pe` I'm using a char array of delimiters. `char delimiters[] = " ( )";` Why does strtok delete the characters between the parenthesis?

Member Avatar
Member Avatar
+0 forum 2

void password(){ string fpass; string pass; cout << "Type the password " << endl; getline(cin,pass); cin.ignore(); ifstream fin(FILENAME1); string str; getline(fin, str); fpass = str; cin.ignore(); if (pass.compare(fpass) == 0){ cout << " Hello!" << endl << endl; cout << "What do you want to do?" << endl; }else{ cout << "\n\n INCORRECT! \n \n \n"; cin.ignore(); char choice; cout << "Try again? y/n --> "; cin >> choice; if (choice == 'y'){ password(); } } } What's the problem with this? It worked, but didn't do what I expected...

Member Avatar
Member Avatar
+0 forum 3

> The following letters are stored in an alphabet array: B, J, K, M, S, and Z. > Write and test a function named adlet(), which accepts the alphabet array and a new letter >as arguments, and then inserts the new letter in the correct alphabetical order in the array. void sortNewArray(char array[], char newLetter) { for (int i = 0; i < newLetter - 1; i++) { if (array[i] > array[i + 1]) { int temp = array[i + 1]; array[i + 1] = array[i]; array[i] = temp; i = -1; } } } void adlet(char array[], char newLetter) …

Member Avatar
Member Avatar
+0 forum 5

Forgive me if this is somewhat basic. If have an array of 20 strings defined: char const commands[20][20] = {// each command string will have a maximum of 20 chars. "quit", "open", "save", "close" }; I want to test the command value to see what action should be taken. int in_array(char array[], char txt[], int len){ for(int i=0;i<len;i++){ if(txt==array[i][0]){ return i; } } return -1; } What is the best way of doing this? I am currently getting an error: `/home/dave/projects/fullpage/action.cpp:15:20: error: invalid types ‘char[int]’ for array subscript` I'd hapily use `include <strings>` but I get a similar error.

Member Avatar
Member Avatar
+0 forum 6

Hi can anyone give me an idea on how I can come out with an output like this: $string = string1-1/string3-3/string3-3/ //this is the original string from DB //i want to split the strings and put it in the array, and the array should look like this Array[0] = String Array[1] = Int Array[2] = String Array[3] = Int ...and so on.. For better understanding of my problem, the string from db that I want to split is a set of strings that I concatenate when the user insert it. Now, I want to split it up into STRINGS and …

Member Avatar
Member Avatar
+0 forum 3

i have this code which tries to enter data into an array of string(char ptr) called token.To do this i have used a while loop to obtain a string as user input and put that string into the token array one by one. But when i try to print the token array outside while loop all the token array elements are equal to the last user entered element in while loop. Output : the screenshot of output is attached in the post. #include<stdio.h> #include<string.h> #include<conio.h> int main(int argc, char **argv) { int i=0,j=0; char *token[20]; char buff[20]; while(i<5) { printf("\nenter …

Member Avatar
Member Avatar
+0 forum 3

I've been assigned in my class to do this exact same problem: <snip> I'm wondering on how to get started. Any help would be appreciated. I know how to use the functions for c-strings, but I'm not sure if I should place all the contents of the paragraph into one char array or if I should look at each piece individually, swap, and then print or should I use a two dimensional array to place each word in a block? Thank you.

Member Avatar
Member Avatar
+0 forum 5

Hi, I need some help with sorting my string comparison. Bascially what I have to do is this: To have numbers sorted properly even when they aren't justified with leading 0's: 1 2 ... 9 10 Instead of: 1 10 2 ... 9 Also to have numbers sorted properly even if they aren't in the lead of the string: a1 a2 ... a9 a10 b1 b2 ... Instead of: a1 a10 a2 ... a9 b1 b10 b2 ... Note how the lead part of the string is sorted and then the numeric part ...almost independently. I would really appriciate some …

Member Avatar
Member Avatar
+0 forum 35

I'm totally new to programming and taking an intro class. When i prompt the user for a state code the program just exits, nothing in my book really goes over this and all im given is crappy youtube videos for reference. Any help is greatly appreciated. #include <stdio.h> #include <stdlib.h> #include <string.h> #define SIZE 2 // initially to test kept it to SIZE 2 typedef struct { char firstName[30]; char lastName[30]; char street[35]; char city[20]; char state[3]; int zip; char phone[15]; int accountId; } Customer; Customer getCustInfo(int a ) { Customer cust; char firstName2[30]; printf(" Enter Data for Customer %d\n", …

Member Avatar
Member Avatar
+0 forum 3

Hi I'm having a little trouble understanding C++ string arguments if that's what you call them. The below example illustrates. I'm not sure I understand what line 14 does. The vector 'myvector' is passed to myfunction (called on line 35. I'm assuming string w takes in the first value of the vector (hence myvector.begin()) and moves this begin position to the next position in the vector (post increment). Does this keep moving the begin() position (hence begin++) as long as there are values in the vector. I'm just not sure how it continually moves through the vector without a loop …

Member Avatar
Member Avatar
+0 forum 2

I'm new to C and I i have an assignment where I have to build a dictionary (Linked List). Basically the user inputs several words,year and their definitio likn this: Example: > love_#_2004_#_LOVING `trade_#_2001_#_INVEST` etc... Now what I need is to have a function that will scan the definition which is in UPPER CASE and give me back the word it relates to. Example: What word would you like to search? Input: INVEST Output: Found "INVEST" in the word "trade". I was kind of answered to that question. It helped understanding what was done but it's unfortunately not enough. The …

Member Avatar
Member Avatar
+0 forum 16

I'm new to C and I i have an assignment where I have to build a dictionary (Linked List in a way). Basically the user inputs several words,year and their definition this: Example: love_#_2004_#_LOVING trade_#_2001_#_INVEST etc... And basically i need a function to scan the definition (Ex: INVEST) and gives me the word trade. If the definition is related to more than only one word to give me back all the words it relates to. What sort of a funtion do I need to scan these strings?

Member Avatar
Member Avatar
+0 forum 14

Hi there, I made a linked list program to add, delete, add in the middle and delete from anywhere. I'm searching to make a function to sort the string data that I have in lexicographic order. Here's my struct: struct node { char data[100]; struct node *previous; // Points to the previous node struct node *next; // Points out to the next node }*head, *last; Any help?

Member Avatar
Member Avatar
+0 forum 5

Hello, I am trying to extract ALL strings between two apostraphes within a given string but for some reason I only seem to be getting the first one. The string I am trying to extract from is: `'1962' '1963' '1964' '1965' '1966'` The code I'm trying to use to get all the extracts is: `var testRE; testRE = results.match("'(.*?)'");` (When I alert the length of testRE it only says 2). Any help is appreciated, thanks!

Member Avatar
Member Avatar
+0 forum 3

The End.