Sunday, August 2, 2009

Write program in c which will which will read a string & rewrite it in the alphabetical order?

ask again in Computer software section .... not authors

Write program in c which will which will read a string %26amp; rewrite it in the alphabetical order?
What he said..then a bunch of if-then commands.


Write a c++ program that convert numeric value to string?

for example:


input: 190.65


output:one hundred ninety and sixty five

Write a c++ program that convert numeric value to string?
Step 1: Convert floating point number to a string using these samples


http://www.cprogramming.com/tips/showTip...


http://www.codeguru.com/forum/showthread...





i.e., 190.65 to





convertedStr = "190.65";





Step 2: Have an array of strings like


text[0] = "";


text[1] = "one";


text[2] = "two";


text[3] = "three";





and lookup for each char in the converted string:





if(convertedStr[0] == '1') output = text[1];

wedding reception flowers

In turbo c programming how can i make a string appear in the center like a marquee?

i want you to answer in details

In turbo c programming how can i make a string appear in the center like a marquee?
here is a simple example, modify it as you want


#include%26lt;stdio.h%26gt;


#include%26lt;conio.h%26gt;


void main()


{


int i;


clrscr();


getch();


for(i=0;i%26lt;40;i++)


{


textcolor(BLACK);


gotoxy(i-1,10);


cprintf("Sachin");


textcolor(GREEN);


gotoxy(i,10);


cprintf("Sachin");


delay(50);


}


getch();


}


A function in C that will count the number of a certain character from a string of characters from the input.?

The user must be able to enter a string of any amount of characters and the output must count only one specific character. Thank you.

A function in C that will count the number of a certain character from a string of characters from the input.?
there is a string function that will do that, I just cant remember what its called. look in the string.h file, or documentation you have for the string functions.





another way is as the other person said. its a pretty easy routine to write, just try it.
Reply:An if statement iterating through the string until it finds the null.... A simple counter variable with an if statement that adds one to the counter every time target is found...


C problem When I'm deleting a string and print it. it doesnt prints blank it prints unknown characters.?

I want to print it blank and not unknown characters

C problem When I'm deleting a string and print it. it doesnt prints blank it prints unknown characters.?
How are you "deleting" the string? I'm a little rusty at C but if I recall correctly strings cant be changed or anything. You probably end up having a pointer to some weird memory address. I believe there is a better class for handling strings called BufferedString. Try using that class instead and see if you still have the weird character problem.
Reply:How are you deleting the string? I'm pretty sure it's doing this because the method you are using is erasing the variable array but not the memory location. It's either that or the string has been set to null.





The next question is, if you just want to cout or printf blank, why not just set the array to all spaces or something?
Reply:Three things come to mind:





1) You are printing something out that doesn't have any meaningful memory assigned to it. Off the top of my head:





int array[4], i;


for ( i = 0; i %26lt; 4; i++ ) {


array[i] = i;


}


printf("Something %d\n", array[4]);





What's happening here is that the array index 4 doesn't point to anything in particular, whatever happened to be lurking in memory there would get output.





2) You actually want to print out spaces:





printf(" ");





would actually print out a blank space.





3) You want to backspace over something that you've output before.





printf("\b");





will print a backspace character. This should "back up" over one character that you've previously printed.


How do u declare a string to be null / empty in C ?

say I got a variable "char[] something = "Hello World" "


Now I want something to be empty, null. How do I do this ?

How do u declare a string to be null / empty in C ?
something.empty();
Reply:char[] something="" or char[] something=NULL. or char[] something=0.
Reply:Actually, if you are using 'C', and you just want the string to be 'empty' (i.e. still be accessable by address, but contain no characters, then you need to set the first character to '\0' (ASCII value 0) since all C strings end with a 'null' character.





Note, this is different from "NULL", which is used to initialize pointers. Now, assuming this is valid ANSI C and you used:





char something[] = "Hello World";





Then you could basically empty the string by using:





something[0] = '\0';





However, be very careful. Because you did not specify a size of the array, you will only be able to copy no more than 12 'char' values into the string (the length of "Hello World" plus its 'null' character). If you were to empty the string, then use strcpy() or other direct means to fill this string array, you would cause stack or heap corruption if you overstep that twelve char boundary.





You can do something like this:





char something[1024] = { "Hello World" };





This will ensure that you have up to 1024 characters of space (minus one for the ending null character) that you can use later to fill up with larger strings.
Reply:string is an array ends with the character \0

flowers gifts

How do you convert a string sentence to an int in C#?

int val = Convert.ToInt32("123");


How would i split a string into a char array in c++ ?

so i have asked the used to enter a word. Let's say they type in "baby"..how would I split it so that I can get an array with array1[b], array1[a], array2[b], array3[y]..thanx in advance

How would i split a string into a char array in c++ ?
http://en.allexperts.com/q/C-1040/Explod...
Reply:string str = "baby";


string arr [str.length];


for(int i=0; i %26lt; str.lenght; i++)


{


arr[i] = str[i];


}

daylily

Simple program of stack using string for push pop functions using c?

Yes, it's simple once you learn how to do it. How are you coming along?

Simple program of stack using string for push pop functions using c?
Simple answer.


How to write a C progamming language that uses a stack to determine if a string palindrome.?

palindrome is a word or phrase which reads the same in both directions.the program should ignore spaces %26amp; punctuation. example or word palindrome is:RACECAR, DEED, LEVEL,PIP,ROTOR,CIVIC,POP, MADAM,EYE,NUN,RADAR,TOOT.Example of phrase palindrome is:LIVE EVIL %26amp; STRAW WARTS. Can anyone help me to write the C programming URGENT.TQ

How to write a C progamming language that uses a stack to determine if a string palindrome.?
It says he has to do it using a stack. Basically you have to create some sort of stack data structure if you don't have one at your disposal. I would just use a linked list and then you need to implement the push, pop, and peek functions that manipulate your linked list. Next you take the word and push each character onto the stack starting at the first character going towards the end. Then you iterate through the input string starting at the end and going towards the beginning. At each character you pop off one character from the stack and compare it to the current character. If they are not equal exit your loop because the input is not a palindrome.
Reply:You need two strings arrays str1[] and str1[]


resverse the str1[] into str2[] and check them for equlance


if(strcmp(str1, str2)==0)


printf("\n String is Plaindrome");


else


printf("\n Not a Palindrome");





strcmp() is used to comapre two strings, it returns 0 if both strings are equal.


What causes this warning in C? warning: cannot pass objects of non-POD type 'struct std::string' through...

warning: cannot pass objects of non-POD type 'struct std::string' through '...'; call will abort at runtime

What causes this warning in C? warning: cannot pass objects of non-POD type 'struct std::string' through...
You are probably trying to pass on a value of a string to a nonstring variable. For example, if you define a variable as an integer and then make it equal a string, it will give you that error.





~WhoCares357


C++: How can I store each word from a sentence as an individual string?

If I ask the user to input a sentence, how can I store each word from that sentence as an individual string? I then want to push each word into a queue, so it's not important that I permanently store each word in a separate variable.

C++: How can I store each word from a sentence as an individual string?
Each word is separated by a space. Hence, your objective is tokenize a string (using spaces), and then store those tokens appropriately.





Since this is C++, I'm assuming you have the sentence in a C++ string. Look at http://www.oopweb.com/CPP/Documents/CPPH... and more specifically the string tokenizer section. If you're not familiar with the various C++ string methods look at http://cppreference.com/cppstring/index....








Specifically the logic is this:


Keep looking for the first space in the string you encounter. Obviously, everything from your current position in the string to the first occurence of the space is the word itself. Therefore, that is your token. Move your current position over to where the space is. Repeat the look for the next space process if you haven't reached the end of the string.





Work through the string tokenizer code and you'll understand.
Reply:use argv[]

flamingo plant

How far from the end of the string should you place your finger to play the note C (523 Hz)?

A violin string is 28 cm long. It sounds the musical note A (440 Hz) when played without fingering.

How far from the end of the string should you place your finger to play the note C (523 Hz)?
There are two equations you'll need.





First, when you play a note on a string, the fundamental frequency causes a standing wave such that the length of the string equals 1/2 of a wavelength. So L = 1/2 wavelength.





Given the legnth of the string above (.28 m), you can figure out the wavelength.


.28 m = 1/2 wavelength


.56 m = wavelength





Second, velocity = frequency x wavelength.


Using the frequency given (440 Hz) and the wavelength just computed, you can find the velocity.





velocity = 440 Hz x .56 m = 246.4 m/s





This speed won't change even as you hold your finger on the string.





Starting with a velocity of 246.4 m/s and a desired frequency of 523 Hz, we can find the wavelength.





velocity = frequency x wavelength


246.4 m/s = 523 Hz x wavelength


.471 m = wavelength





Using this wavelength and the fact that the length of the string is 1/2 of a wavelength long, you get:





Length of string = 1/2 wavelength


Length of string = 1/2 (.471 m)


Length of string = .236 m





Since the question asks how far from the end you should place your finger, take the original string length and subtract the answer above.





distance from end = .28 m - .236 m = .044 m or 4.4 cm.


I am using C++ and I need help with a program question dealing with string/function call)?

Let's say I have a function defined as





str_call (int x)





When I do str_call(0), I want the function to return the string


"Ninety"...





How can I write up the function? I have no experience dealing with strings.

I am using C++ and I need help with a program question dealing with string/function call)?
See below for an example of a function that returns a string. The functionality you're looking for calls, I think, for a lookup table. The example also illustrates that.





By the nature of your question, I assume you're something of a beginner in C++. Some of the things you see below may be new to you, but it's never too soon to learn. C++ offers many useful features, and you should learn to take advantage of them.





#include %26lt;iostream%26gt;


#include %26lt;string%26gt;


#include %26lt;map%26gt;





using namespace std;





typedef map%26lt;int,string%26gt; LookupTable;


typedef pair%26lt;int,string%26gt; LookupTableElement;





string translate(int,const LookupTable%26amp;);





int main(int argc, char *argv[]) {


LookupTable lookup;





// Initialize


lookup.insert(LookupTableElement(0,strin...


lookup.insert(LookupTableElement(1,strin...


// ...


lookup.insert(LookupTableElement(90,stri...





// Translate


cout %26lt;%26lt; translate(90,lookup) %26lt;%26lt; endl;


cout %26lt;%26lt; translate(99,lookup) %26lt;%26lt; endl;





return 0;


}





string translate(int x,const LookupTable%26amp; map) {


LookupTable::const_iterator i;


if ((i = map.find(x)) != map.end()) {


return i-%26gt;second;


} else {


return string("not found");


}


}





// Program output:


// ninety


// not found
Reply:I doubt you're dumb, you just haven't learned enough C++ yet. For now, you can skip over the more complicated stuff. The fundamentals of what you asked for - how to return a string from a function - are fairly simple, and clearly shown in my 'translate' function. Report It

Reply:When dealing with strings as output parameters of functions, it's best to provide the function a buffer for filling it up. For example:





bool str_call(int x, char *result, int resultSize)


{


if (x==0)


{


if (resultSize%26gt;=strlen("Ninety")) // check to see if the provided buffer is big enough


{


strcpy(result, "Ninety");


return true; // return a successfull return code


}


}





return false; // result isn't valid


}





void main()


{


char result[100] = { '\0' };





if (str_call(0, result, sizeof(result))==true) // Calling the str_call function


{


printf("%s\n", result);


}


};





// Have fun,


// S. B.
Reply:You have two options. If you only ever want to return the one string, "ninety", then you can do this:





char *str_call(int x)


{


return "ninety";


}





my_other_function()


{


printf ("%s\n", str_call(0)); // Prints "ninety"


}








This is OK, but it's a bit limited. A better option would be to have something like this:








char *str_call(int x, char *storage)


{


strcpy(storage, "ninety");


return storage;


}





my_other_function()


{


char str[20];


printf ("str_call returns %s\n", str_call(0, str)); // Prints "str_call returns ninety"


printf ("Also, str = %s\n", str); // Prints "Also, str = ninety"


}








For completeness it's better to set limits on the size of these arrays, so you'd have this:





char *str_call(int x, char *storage, int maxlen)


{


strncpy(storage, "ninety", maxlen);


return storage;


}





my_other_function()


{


const int strSize = 20;


char str[strSize];


printf ("str_call returns %s\n", str_call(0, str, strSize)); // Prints "str_call returns ninety"


printf ("Also, str = %s\n", str); // Prints "Also, str = ninety"


}








Finally, if you're using C++ then you may as well also use the benefits of STL like this:





void str_call(int x, std::string %26amp;storage)


{


storage = "ninety";


}





my_other_function()


{


std::string str;


str_call(0, str);


printf ("str = %s\n", str); // Prints "str = ninety"


}
Reply:Have a read about pointers.





Strings are arrays of characters. when passing an array, you should pass a pointer the memory address of the first element in the array.





char mystring[50]





char* StringFunction(int x){


char mystring2[50];


strcpy(mystring2, "Ninety");


return mystring2;


}





int main(){


mystring = StringFunction(0);


cout %26lt;%26lt; mystring;


return 0;


}


__





I havnt been learning C++ long, but try compiling that. I can't garuntee it is the most efficient way even if it does work, but it might give you a start
Reply:go to www.freeprogrammersheaven.com and search you can learn and will get the answers


Which string is better for panties: g, c, or v?

IF you are a boy, G-string are very sexy and nice to wear.


You have also bikini string panties.


Just go to frederick of hollywood.com and you will find out a lot for boys and girls.

Which string is better for panties: g, c, or v?
g


I want to tokenize the string using the delimiter :some @.How to do this in C#.net?

Eg:suppose some string"My name@is xxx.@I am doing @so and so"


actually my intention is to store all these tokens in different variables.


let me say


x = My name


y = is xxx.


z =I am doing


a =so and so








Actally i know how to do it in java using the string tokezier.How to


do this in .Net.


Please help me.








Thanks in Advance..

I want to tokenize the string using the delimiter :some @.How to do this in C#.net?
string field = "My name@is xxx.@I am doing @so and so"


string[] result = field.Split(new char[]{'@'});

umbrella plant

How far from the end of the string should you place your finger to play the note C (523 Hz)?

A violin string is 28 cm long. It sounds the musical note A (440 Hz) when played without fingering.

How far from the end of the string should you place your finger to play the note C (523 Hz)?
There are two equations you'll need.





First, when you play a note on a string, the fundamental frequency causes a standing wave such that the length of the string equals 1/2 of a wavelength. So L = 1/2 wavelength.





Given the legnth of the string above (.28 m), you can figure out the wavelength.


.28 m = 1/2 wavelength


.56 m = wavelength





Second, velocity = frequency x wavelength.


Using the frequency given (440 Hz) and the wavelength just computed, you can find the velocity.





velocity = 440 Hz x .56 m = 246.4 m/s





This speed won't change even as you hold your finger on the string.





Starting with a velocity of 246.4 m/s and a desired frequency of 523 Hz, we can find the wavelength.





velocity = frequency x wavelength


246.4 m/s = 523 Hz x wavelength


.471 m = wavelength





Using this wavelength and the fact that the length of the string is 1/2 of a wavelength long, you get:





Length of string = 1/2 wavelength


Length of string = 1/2 (.471 m)


Length of string = .236 m





Since the question asks how far from the end you should place your finger, take the original string length and subtract the answer above.





distance from end = .28 m - .236 m = .044 m or 4.4 cm.


How do you tune a 6 string electric guitar to drop d tuning and drop c tuning?

either with an electric tuner or without i have an electric tuner i just dont know what to tune it to for drop c and drop d

How do you tune a 6 string electric guitar to drop d tuning and drop c tuning?
Dropped C tuning is an alternative guitar tuning style in which the lowest (sixth) string is tuned down two tones ("dropped") to C and the rest of the strings are tuned down one tone, thus making the overall tuning CGCFAD from low to high. Although popularly referred to as "Drop C", CGCFAD tuning is not in fact "Drop C" tuning; a "drop" tuning refers only to the dropping of the tuning of the lowest string; thus "Drop C" tuning is actually CADGBE and the tuning referred to is actually "Drop D, tuned down one whole step (tone)."[1] Throughout the rest of this article, what is referred to as drop C is CGCFAD, or drop D tuned down one whole step.





Dropped D tuning: DADGBE, also known as simply as drop D, is an alternate guitar tuning style in which the lowest (sixth) string is tuned down one whole step ("dropped") to D rather than E as in standard tuning (EADGBE or EADG).,


What's wrong with my C#.net code ,im trying to join a bunch of string and integers together.?

udate.Text = "Hello, " + DateTime.Now.DayOfWeek.ToString().Substr... 3) %26amp; " " %26amp; DateTime.Now.Day %26amp; ", " %26amp; definemonth() %26amp; " : You are not logged in.";


The error is at "Hello, " part it said ''Operator '%26amp;' cannot be applied to operands of type 'string' and 'string"

What's wrong with my C#.net code ,im trying to join a bunch of string and integers together.?
Concatenation in C# is done with + not %26amp;


How do i make a program in c language that extracts the suffix of a word/string?

ex: String: Department


prefix: Depart


suffix: ment

How do i make a program in c language that extracts the suffix of a word/string?
try looking it on the web
Reply:Shouldn't you ask this in a different section? Most of us here know languages but not computer-programming.
Reply:I sincerely doubt that you'd be able to make a program which can truly capture the complexity of morphology. Just as internet translators are notoriously inadequate, a computer program would have to understand morphology like a human does, and so far I've seen very little evidence that this is possible.

deliver flowers

I need to write a C++ program that determines if a string is a palindrome?

i need this program for a assignment

I need to write a C++ program that determines if a string is a palindrome?
Set up a for loop starting at the length of the string and moving backward one character at a time until you reach the first character.





Inside the loop copy the character you are at to the end of a new string which you dimensioned the same size as the original .





When you reach the end of the first string all of the characters should be copied in reverse order to the second string.





Now just compare your original string to the new string if they are equal then the original sting was a palindrome.
Reply:This should not be too bad. I don't know c++ at all, but you should be able to loop on the number of letters in the string. Here is some pseudo-code





if (n is odd) // n is the length of the string


{lengthToCheck = (n-1)/2}


else


{lengthToCheck = n/2}


endif





palindrome = true


for i= 1 to lengthToCheck


{if(i-th element in string %26lt;%26gt; n+1-i-th element in string) then


{palindrome = false


exit(false)


}


}





That should do it. Hope this is helpful from someone who knows very little C++ code.


C program recursive method (find the character index in the string)?

str = "Hello world"


ch = "w"


use recursive method, no string.h function


return 'w' index = 6





int findIndexString(char str[ ], char ch)

C program recursive method (find the character index in the string)?
again, like before! I really hv too much time in my hands today :-p





#include %26lt;stdio.h%26gt;





int findIndexString(char str[], char ch) {


int pos;


if (*str=='\0') {


return -1;


}


if(*str==ch) {


return 0;


}


pos = findIndexString(++str, ch);


if (pos%26lt;0) {


return pos;


} else {


return pos+1;


}


}


int main() {


char str[25]="hello world";


int pos = findIndexString(str, 'h');


printf("The position is %d\n", pos);


}
Reply:Hello,





I suppose this is just for fun? If so, ok.





Else please note It is particularly inefficient to use recursiveness for such low level functions. You put the system under heavy strain due to call stack adjustments needed to accomodate the numerous function calls (passing variables).
Reply:int findIndexString(char str[],char ch)


{


static int i=0;


if(*str =='\0')


return 0;


else if(*str == ch)


return i;


else{


i++;


return findIndexString(++str,ch);


}





}


Converting a string, to a vector of ints, to binary, to hexadecimal. (C++)?

I need to create a program that will accept a string inserted by the user, which represents an unsigned int. I need to convert this string to a vector of ints, and then convert the number to binary and hexadecimal. This is what I have so far:





#include %26lt;iostream%26gt;


#include %26lt;vector%26gt;


#include %26lt;string%26gt;


#include %26lt;cstdlib%26gt;





using namespace std;


int main(void)


{


cout%26lt;%26lt;"Input a decimal:"%26lt;%26lt;endl;


string s;


cin%26gt;%26gt;s;





vector%26lt;int%26gt;n(s.length());





for(int i = 0; i %26lt; n.size(); i = i + 1)


{


n[i] = s[i] - 48;


}





return 0;


}

Converting a string, to a vector of ints, to binary, to hexadecimal. (C++)?
Your code assumes that the string entered only contains ASCII digits. You should explicitly check for this:





if ( isdigit( s[i] ) ) {





Next, you can also use a standard function to convert a string to an integer for you:





n[i] = atoi( s[i] );





(if you ever want to convert the entire string to a single integer, you could use strtol() ).





Give these a whirl and see where you end up. Go to the URL below and type "atoi" in the search field.


Can u please give me an example of for loop,int,string and char?? in turbo c?

i need more some examples ...... please help me... so that I can review much in my coming exam.....

Can u please give me an example of for loop,int,string and char?? in turbo c?
Integer


any numbers from 0 to 9 you can feed in a int variable.


eg:


int year; - contains the numbers


year=1990;





String


A group of alpha(A-Z and a-z), numeric(0-9) and special characters kept in a variable is string.


eg.


string date;


date="19.02.2006";





char


each and every position in a string contains a char.


char usually contains only one letter.


char date_seperator;


date_seperator="/";





for loop


to repeat a operation for defined number of times use for loop.


eg. to print date starting from 0-30





int date=0;


string month="June";


String year="1990"


char date_seperator ="/";








for (date=0;date%26lt;=30;i++)


{


printf(date+date_seperator+month+date_...


}








hope this helps you to understand better. :)

floral bouquets

What is the function C++ to reserve the null terminated string that is passed in. library func use strlen()?

c++ doesnot have its own you have to implement it.


How to read a string from a text file in asp.net using c#?

Actually, I put a connection string in a text file and I need to read the connection string from it. Below, is my text code, but still can't made it.





string FILENAME = System.Web.HttpContext.Current.Server.Ma...





StreamReader objStreamReader;


objStreamReader = File.OpenText(FILENAME);


m_strConnString = objStreamReader.ReadToEnd();


objStreamReader.Close();





Can anybody help me? Thanks.

How to read a string from a text file in asp.net using c#?
you can do this much more effectively w/ configuration files. Add a Web.Config file to your project and add a connectionstring element. then read the value out via the ConfigurationManager static class. This is by far the preferred solution as .config files are automatically blocked by IIS and cannot be downloaded by bots, malicious users, etc.





Example provided is in VB.Net, but you should be able to get the gist =)
Reply:Connection strings should be placed in configuration files instead of text files.





Thats exactly what configuration files are for. Application wide (or machine wide) configurations.





Hope this helps.


Is the Schecter C-5 bass a good five string?

You can get one new for $550, Im gonna try to find one used though.

Is the Schecter C-5 bass a good five string?
my friend has one and it sounds and feels really good...for 550 thats a good deal





AE
Reply:schecter is a very good brand. i got my ex an a-7 elite guitar for his b-day a few years ago.... beautiful guitar. if you can't find a used c-5, then you should def get a new one... it's worth the money .


In Visual C++, I want to read a string from a text file, and assign it to a variable?

But for some reason I have programmer's block and am not quite sure of how to do it. I guess that's what happens when you've been looking at code for three days straight, all day long. I have attempted to do so by trying to force myself to think creatively, but my attempt is quite obviously flawed.





For instance, I have a variable called "fullscreen_x". I want this variable to be assigned information from a specific point on a specific line of a text file (like a user configuration file).





Basically, I just want to know how to read information from a text file. Thanks

In Visual C++, I want to read a string from a text file, and assign it to a variable?
Fred: A disgrace how you answer straight away with full code; you are encouraging laziness. Give hints and algorithms and let the asker implement them rather than showing up.





For the asker:


one of many variation to solve your problem would be:


1.) Read the file


2.) store the content into a data structure (vector, list ...etc.)


3.) Implement a search module which will iterate through that data structure


4.) Tokenize the search result and format it


5.) Assign that result to the variable
Reply:I do it somewhere in there.....I'm to lasy to pick it out....its part of fstream...that is how you open a file read from it into a string, then output to a file, this was compiled with GNU though...hope it still helps














big_int_calc.cpp





A program that will read in a large integer from a file then preform calculations on the number. It will then output the result into another file.








*/





#include%26lt;iostream%26gt;


#include%26lt;fstream%26gt;


#include"big_int.h"


#include"char_to_int.h"





int main(){


//ask the user for options and store as an integer


int option;


std:: cout %26lt;%26lt; '\n'%26lt;%26lt; "Enter an option: " %26lt;%26lt; '\n';


std::cout %26lt;%26lt; "1. Read a big intger from file and add" %26lt;%26lt; '\n';


std::cout %26lt;%26lt; "2. Enter big integer,and multiply by 10^n" %26lt;%26lt; '\n';


std::cout %26lt;%26lt; "3. Multiply an integer read from file" %26lt;%26lt; '\n';


std:: cin %26gt;%26gt; option;





//big int to store result in


big_int result;


//big int to store input data


big_int in_data1, in_data2;





if(option == 1){


//variable to store the file name


char file_name[20];





//ask the user for the name of the file they would like to read from


std:: cout %26lt;%26lt; "Enter the file name you would like to read a big integer from: ";


//input of the file name


std:: cin %26gt;%26gt; file_name;





//opens the file, if file is not opened error is output


std::ifstream in;


in.open(file_name);





// outputs error if needed


if(!in){


std::cout%26lt;%26lt; "Error cannot open file" %26lt;%26lt; '\n';


};





//read the data from the file into a C-array that is a member of the class big_int











int index = 0; // variable to try and make the array size itself


bool second_num = false; // variable to declare when to start second number input


int i = 0; //i is used as the index, but is also the size of the array for in_data1


while(!in.eof()){


char temp;


in.get(temp); // stores the value of the char read in into temp





if(temp != '\n' %26amp;%26amp; temp != '+'){ //filters new line char and +





if(temp == ';'){ // checks for the second number





second_num = true; //sets the value of second num to true once ; is read


// the size of the first big int will be i -1


i = 0; // resets the index


};


//reads first number


if(second_num == false){


in_data1.num_array[i] = char_to_int(temp); //stores value as integer in big_int data type


++i;


in_data1.set_array_size(i); // sets the size of the array


};





//reads in second number with filters


if(second_num == true %26amp;%26amp; temp != ';'){ //filters out ; that may be at the end of the file


in_data2.num_array[i] = char_to_int(temp); //stores the value as an integer in big_int


++i;


in_data2.set_array_size(i); // sets the value of the array size


};


};


};





// variable that decides if user wants to output to screen or file


int result_option;


if(option == 1){


//calculates result


result = in_data1 + in_data2;


//ask user for the input of the option


std::cout%26lt;%26lt; '\n' %26lt;%26lt; "To output result to screen enter 1, to output to file enter 2: ";


std:: cin %26gt;%26gt; result_option;


result = in_data1 + in_data2;


if(result_option == 1){


std::cout %26lt;%26lt; "The result is: " %26lt;%26lt; '\n';


result.output();


std::cout %26lt;%26lt; '\n';


};





};





// outputs to file if option is 2


if(result_option == 2){


//calculates result


result = in_data1 + in_data2;


//ask the user the name of file to write to


std::cout %26lt;%26lt; "Enter the file name to write to: " %26lt;%26lt; '\n';


char outfile_name[20];


//declares the file to be written to


std::cin %26gt;%26gt;outfile_name;


std::ofstream outfile(outfile_name, std::ios::app);





// format output


outfile %26lt;%26lt; "The result is: " %26lt;%26lt; '\n';


for(int i = 0; i %26lt; result.size(); ++i){


outfile %26lt;%26lt; result.num_array[i];


if( i % 50 == 0 %26amp;%26amp; i %26gt; 0){ //starts new line every 50 char


outfile %26lt;%26lt; '\n';


};





};


// output of ; at end of file


outfile %26lt;%26lt; ';';











};


};





// declares a big int entered int which is entered by the user


big_int entered_int;


if(option == 2){


//ask the user what they would like to do with the result


int output_option;


std::cout %26lt;%26lt; "To output to screen enter 1, to output to file enter 2: ";


std::cin %26gt;%26gt;output_option;


char temp;


char int_in[500];





//inputs the big integer to the big_int class array


int index = 0;


std::cout %26lt;%26lt; "Enter big integer with e to end input: " %26lt;%26lt; '\n';


//uses sential value to end input


while(std::cin%26gt;%26gt; temp){


if(temp == 'e'){


break;


};


//converts the char to integers


entered_int.num_array[index] = char_to_int(temp);


++index;


};


//inputs the value of n


entered_int.set_array_size(index);


std::cout %26lt;%26lt; "Enter n (10^n) n=";


int n;


std::cin%26gt;%26gt; n;


for(int i = 0; i %26lt; n; ++i){


//adds 0's on the end of the array


entered_int.num_array[entered_int.size()... = 0;


};


// sets new array size


entered_int.set_array_size(entered_int.s... + n);


if(output_option == 1){


std::cout %26lt;%26lt; "The result is: " %26lt;%26lt; '\n';


entered_int.output();


};





if(output_option == 2){


//writes to file if user chooses that optioin


std::cout %26lt;%26lt; "Enter the file name to write to: " %26lt;%26lt; '\n';


char outfile_name[20];


std::cin %26gt;%26gt;outfile_name;


std::ofstream outfile(outfile_name, std::ios::app);





//formats output with 50 char per line


outfile %26lt;%26lt; "The result is: " %26lt;%26lt; '\n';


for(int i = 0; i %26lt; entered_int.size(); ++i){


outfile %26lt;%26lt; entered_int.num_array[i];


if( i % 50 == 0 %26amp;%26amp; i %26gt; 0){


outfile %26lt;%26lt; '\n';


};





};


//adds ; at end of file


outfile %26lt;%26lt; ';';











};


};











// variable that decides if user wants to output to screen or file


int result_option;


if(option == 3){


//variable to store the file name


char file_name[20];





//ask the user for the name of the file they would like to read from


std:: cout %26lt;%26lt; "Enter the file name you would like to read a big integer from: ";


//input of the file name


std:: cin %26gt;%26gt; file_name;





//opens the file, if file is not opened error is output


std::ifstream in;


in.open(file_name);





// outputs error if needed


if(!in){


std::cout%26lt;%26lt; "Error cannot open file" %26lt;%26lt; '\n';


};





//read the data from the file into a C-array that is a member of the class big_int











int index = 0; // variable to try and make the array size itself


bool second_num = false; // variable to declare when to start second number input


int i = 0; //i is used as the index, but is also the size of the array for in_data1


while(!in.eof()){


char temp;


in.get(temp); // stores the value of the char read in into temp





if(temp != '\n' %26amp;%26amp; temp != '+'){ //filters new line char and +





if(temp == ';'){ // checks for the second number





second_num = true; //sets the value of second num to true once ; is read


// the size of the first big int will be i -1


i = 0; // resets the index


};


//reads first number


if(second_num == false){


in_data1.num_array[i] = char_to_int(temp); //stores value as integer in big_int data type


++i;


in_data1.set_array_size(i); // sets the size of the array


};





//reads in second number with filters


if(second_num == true %26amp;%26amp; temp != ';'){ //filters out ; that may be at the end of the file


in_data2.num_array[i] = char_to_int(temp); //stores the value as an integer in big_int


++i;


in_data2.set_array_size(i); // sets the value of the array size


};


};


};





//calculates result


result = in_data1 * in_data2;


//ask user for the input of the option


std::cout%26lt;%26lt; '\n' %26lt;%26lt; "To output result to screen enter 1, to output to file enter 2: ";


std:: cin %26gt;%26gt; result_option;


if(result_option == 1){


std::cout %26lt;%26lt; "The result is: " %26lt;%26lt; '\n';


result.output();


std::cout %26lt;%26lt; '\n';


};





};





// outputs to file if option is 2


if(result_option == 2){


//calculates result


result = in_data1 + in_data2;


//ask the user the name of file to write to


std::cout %26lt;%26lt; "Enter the file name to write to: " %26lt;%26lt; '\n';


char outfile_name[20];


//declares the file to be written to


std::cin %26gt;%26gt;outfile_name;


std::ofstream outfile(outfile_name, std::ios::app);





// format output


outfile %26lt;%26lt; "The result is: " %26lt;%26lt; '\n';


for(int i = 0; i %26lt; result.size(); ++i){


outfile %26lt;%26lt; result.num_array[i];


if( i % 50 == 0 %26amp;%26amp; i %26gt; 0){ //starts new line every 50 char


outfile %26lt;%26lt; '\n';


};





};


// output of ; at end of file


outfile %26lt;%26lt; ';';











};








/*


if(option == 4){


std::cout %26lt;%26lt; "Input a number to calculate the factorial of: ";


int fact_in;


std::cin %26gt;%26gt; fact_in;


big_int result;


result = fact(fact_in);


std::cout %26lt;%26lt; '\n' %26lt;%26lt; "Enter 1 to output to screen, enter 2 to output to file: " ;


int result_option;


std:: cin %26gt;%26gt; result_option;


if(result_option == 1){


result.output();





};


// outputs to file if option is 2


if(result_option == 2){





//ask the user the name of file to write to


std::cout %26lt;%26lt; "Enter the file name to write to: " %26lt;%26lt; '\n';


char outfile_name[20];


//declares the file to be written to


std::cin %26gt;%26gt;outfile_name;


std::ofstream outfile(outfile_name, std::ios::app);





// format output


outfile %26lt;%26lt; "The result is: " %26lt;%26lt; '\n';


for(int i = 0; i %26lt; result.size(); ++i){


outfile %26lt;%26lt; result.num_array[i];


if( i % 50 == 0 %26amp;%26amp; i %26gt; 0){ //starts new line every 50 char


outfile %26lt;%26lt; '\n';


};





};


// output of ; at end of file


outfile %26lt;%26lt; ';';








};


};


*/





return 0;


};

dried flowers

Need a short c++ program that counts how many words in a string?

cin%26gt;%26gt;"this is a test"


cout%26lt;%26lt; x %26lt;%26lt; "words in your string";





where x is determined to be 4 by some short function.

Need a short c++ program that counts how many words in a string?
the simplest one would be to count the no. of spaces in the string and report %26lt;%26lt;no_of_spaces+1 .


that's ofcourse the most basic program.. and it'll give u wong results more often than not.





ican post u the exact code.. (the perfect program) for this.. if u really need.. but it'll ofcourse take some time
Reply:Oh come on -- this is too easy to ask for help with. How far are you going to get asking someone else to do your homework for you?





Look, this is the basic pseudocode:





x = 0


while not (end of string) do {


if (current character is a blank space){


if (next character is not a blank){


x = x + 1


}


}


}


return x





that's basically it.


I am having trouble soloing with two string scales,(mexican music), how does c scale go on the bottom strings?

using the e and b strings together for one note is what i mean

I am having trouble soloing with two string scales,(mexican music), how does c scale go on the bottom strings?
ask in music instrument section or google it


Strings in C++?

Why can't I compile this program in Turbo C++\


#include%26lt;iostream.h%26gt;


#include%26lt;conio.h%26gt;


#include%26lt;strng.h%26gt;


void main()


{


string c;


cin.getline(c,10);


cout.write(c,10);


getch();


}

Strings in C++?
Fix the include statement.





#include%26lt;string%26gt;


using namespace std;





After doing that, the compiler error about 'string' being unidentified should go away.





Now you will get compile errors about using 'c' as if it were a char* in getline. It's not, it's a class basic_string and getline() wants a char*





Though basic_string has a .c_str() method to convert itself into to a const char*, that's not good enough and the compiler will still complain. getline( ) needs a non-const char*. Even if you forcefully cast it to a char*, you'll get an access violation at runtime.





To use getline, you'll need a char*. You can then assign that to the string. It's really not the best example of using a string class, because you're calling methods that won't take a string, and you're not using any of the cool stuff that the string class will do for you. This will compile and run, though:





string c;


char read[10];


cin.getline(read,10);


c = read;


cout.write(c.c_str(),10);


getch();
Reply:you mispelled string.





#include %26lt;string.h%26gt;





if that doesn't, then do it manually with


char mystring[10]
Reply://Ahmm it's the string...


//there is no string or boolean on c++


{


char c[100];//Or char *c;


cin.getline(c,10);


cout.write(c,10);


getch();


}
Reply:try loading %26lt;string.h%26gt;


When using c++ i need an example code of a broken string?

like what it is for example 1,2,3,4,5ive is what i have seen in examples but i dont under stand how a string can brake and y it brakes and if possible an any 1 explain y using globle varibles is so bad

When using c++ i need an example code of a broken string?
You need to slow down.





Learn English first (no offense - or ask this question in a forum that is in your native language), then take basic class on C programming before going into C++.

gift baskets

I am having trouble soloing with two string scales,(mexican music), how does c scale go on the bottom strings?

using the e and b strings together for one note is what i mean

I am having trouble soloing with two string scales,(mexican music), how does c scale go on the bottom strings?
tryasking in the music/ instrument section


In Winapi (Visual C++) , how do i get a string "EQ1" from my string list into my resource box "QUESTIONBOX" ?

My current code is:





SetDlgItemText (hwnd, QUESTIONBOX, EQ1)





It returns an error, saying that it cannot convert from const int to const char :S





Hmm wat if i use SetWindowText..


Could someone paste in the exact code i need to type to make this work. thanks.

In Winapi (Visual C++) , how do i get a string "EQ1" from my string list into my resource box "QUESTIONBOX" ?
The following link from Microsoft shows an example on


how to use "SetDlgItemText"





http://msdn.microsoft.com/library/defaul...





SetDlgItemText(hDlg, IDS_POS, Roster[i].tchPosition);





May be this can help you


In C++, how do you print quotation marks with an string in the middle?

For example:


I want to print:


" Blah blah blah "





Blah blah blah is a string.





it won't work like this:


cout %26lt;%26lt; "Movie name: " %26lt;%26lt; setw (30) %26lt;%26lt; "\" %26lt;%26lt; movieName \"" %26lt;%26lt; endl;

In C++, how do you print quotation marks with an string in the middle?
It looks like your line should be like this:





cout %26lt;%26lt; "Movie name: " %26lt;%26lt; setw (30) %26lt;%26lt; "\"" %26lt;%26lt; movieName %26lt;%26lt; "\"" %26lt;%26lt; endl;





You need to use "\"" when you want a string that just contains a double-quote character
Reply:I thought that \" worked.
Reply:Your code not work becuse you must write:


cout %26lt;%26lt; "Movie name:" %26lt;%26lt; setw(30) %26lt;%26lt; "\"" %26lt;%26lt;moveName "\"" %26lt;%26lt;endl;


an other example:


to output : Blah "BLAH" blah


you must write:


cout%26lt;%26lt;"Blah \"BLAH\" blah";


C program, use recursive method find string length?

why do I get the feeling that this sounds like a homework assignment? I am giving a very small code that demonstrates the principle. I absolutely will not recommend something like this for any form of deployment





#include %26lt;stdio.h%26gt;





int findlen(char * s) {


int len;


if (*s == '\0') {


return 0;


}


len = findlen(s+1);


return len+1;


}





int main() {


char str[25]="hello world test";


int len = findlen(str);


printf("length = %d\n", len);


}

C program, use recursive method find string length?
U will find the code here:


http://www.codeguru.com/forum/showthread...
Reply:Strings in c are represented as some series of ascii characters followed by the NULL ascii character (represented numerically as 0). So, to do it recursively, our else case increments some variable (the length of the string) while our base case checks to see if the current location in the string is 0 or not. If so, we are done.





//assume we have the value at pointer length is initialized to 0


char strlen (char* s, int* length) {


if (!*s) {


return;


}


else{


*length++;


strlen(s++,length);


}


}





It could be written more efficiently, but you get the idea.
Reply:See here, you may find the answer: http://www.codeproject.com

wedding

C programe that can transger a string "Hello", to another connected computer. after receving "Hello, the rece

Your question is quite confusing! Can you rephrase your question?

C programe that can transger a string "Hello", to another connected computer. after receving "Hello, the rece
Are you talking about a C++ program ? Your question is confusing. However, you need to network two computers so that the C++ compiler can communicate with the other C++ compiler. You need to find out how to network computers


C program to print a particular string for hundred times without any condition statements?

The following program would do the trick.


#include %26lt;stdio.h%26gt;





int c=101;


int f()


{


c=c-1;


c %26amp;%26amp; printf ("The string \t") %26amp;%26amp; f();


return 1;


}


void main()


{f();}





Hope this solves your problem.


-Regards, Rahul

C program to print a particular string for hundred times without any condition statements?
No conditional statements doesn not mean no loops ;)


FOR loop dude!


for (int i=0; i%26lt;399;i++)
Reply:Thats a stupid question. The only solution is to type printf("string"); 400 times.





You get no benefit. Use a damn for loop.
Reply:write this line hundred times


printf("Your string...");


In C++, how do you convert an integer into a string or character?

For example, I want to be able to read in the int 65 and for it to return the string or char "a". I want it to do this for every number entered. Is there a member function that does this?

In C++, how do you convert an integer into a string or character?
Char to Int





char word = 'a';


cout %26lt;%26lt; (int)a;


Displays: 65





Int to Char





int Number = 65;


cout %26lt;%26lt; (char)Number;


DIsplays: a
Reply:try


itoa();





function ,its a C function though will work fine,


im bit sure...
Reply:Msdn is a great source for code and examples. However like in most other languages you would use the TryParse method. For example in C# it would be:





int one;


char[30] two;





Tryparse.Int32(one, two);
Reply:the first answer: casting the int to char using (char) a is the correct answer.





itoa() will return the string "65".





There is nothing in C++ like TryParse. Dear answerer, if you have learnt something in some language or it's associated library, try and keep it limited to that language and not assume that it is a very common thing available in all programming languages.





Actually the commonality between programming languages are more of exceptions than rules.
Reply:try (char)


like


int a = 65;


char b = (char)a ;


C program to find wheather the string is palindrome or not..friends please help!!?

we can do this using the string functions





#include%26lt;stdio.h%26gt;


main()


{


char a[20],b[20];


printf("enter a string");


scanf("%s",%26amp;a);


strcpy(b,a);//copies string a to b


strrev(b);//reverses string b


if(strcmp(a,b)==0)//compares if the original and reverse strings are same


printf("\n%s is a palindrome",a);


else


printf("\n%s is not a palindrome",a);


return 0;


}

C program to find wheather the string is palindrome or not..friends please help!!?
Hey thats an excellent trick of finding whether palindrome or not. Good. Keep going..... Report It

Reply:palindrome: It is a word, phrase, number or other sequence of units that has the property of reading the same in either direction.for example:"madam",it can be read in both the directions..


void main()


{


//first read a string A from the key-board using scanf().


// now reverse the given string and store the


//resultant in string C.compare strings A and C using string


//handling functions "strcmp".if it is true then print that string is


//palindrome else print that the string is not palindrome


}

flowers on line

C++: Changing a number into a string of chars?

How would I change an int variable which is 12345 into a char array with [1,2,3,4,5]?





Tell be the corresponding library please, if there is one.

C++: Changing a number into a string of chars?
Use sprintf.





char buf[32];


sprintf(buf, "%d", nValue);





where nValue is your int variable.
Reply:How about incorporating a straight c fix:





#include %26lt;stdio.h%26gt;


int yo = 12345;


char buf[30];


sprintf(buf, "%d", yo);





or if you use a char to hold initially 12345, then it is already in an array.





for(int i = 0; i %26lt; strlen(buf); i++)


printf("%c\n", buf[i]);


How do i convert numbers in string format to int in c#?

int x = int.Parse("123");

How do i convert numbers in string format to int in c#?
You would use the Int32.Parse() method; however, this method will throw an exception if the string that is passed to it is not a valid sequence of characters that defines an integer.





One thing I like to do (and this method can be overloaded since it differs by parameter type as well as return type) is to take a string and an second parameter as a default value if it fails. You would then have something like:





int GetValue(string data, int defaultValue)


{


int result = defaultValue;





try { result = Int32.Parse(data); }


catch { }





return result;


}
Reply:Something like this should work for you





public int convertStringToInt(string strSource)


{


try


{


return int.Parse(strSource);


}


catch


{


return null;


}





}


How to input a binary string bit by bit in C?

input a string array in the same way u do for integers.


char arr[20];


for(int a=0;a%26lt;=20;a++)


{


scanf("%c",%26amp;arr[a]);


}

How to input a binary string bit by bit in C?
Strait C? Not C++... boy it's been a long time!





I would recommend storing the values in a char array and then converting the result after it was all input.





#include %26lt;stdio.h%26gt;


char line[100];


printf("Enter Binay String");


fgets(line, sizeof(line), stdin);
Reply:Use cin in a for loop?
Reply:/* this code will promt u to enter d string until u press ENTER key.....





char ch;


char string[100];


int i=0;





while( ch != 13) // 13 is ascii value for "enter" or carriage return..


{


ch = getchar();


string[i]=ch;


i++;


}


How do i put a string into an array in c language?

declare it as an array

How do i put a string into an array in c language?
create a character array and copy the string into the array?

florist shop

What is the easiest way to determine if a string is a number in c#?

Convert.ToInt32()


will convert char's and strings





I am trying to get


Int32.TryParse(Console.ReadLine(), System.Globalization.NumberStyles.Intege... IFormatProvider, out searchZip);





..to work but wtf is an IFormat provider and is there a simple version of one that I can use or make?





...what is the simplest way to do this?





for my purposes 99999 is a number and 99,999 is not a number. wererewoiy definately is not a number.

What is the easiest way to determine if a string is a number in c#?
public static bool IsNumeric(object Expression)


{


bool isNum;


double retNum;


isNum = Double.TryParse(Convert.ToString(Express... System.Globalization.NumberStyles.Any,Sy... out retNum );


return isNum;


}





Try this


In C++ what is the easiest way to convert a string (std::string) to type int?

Lets say I have a String number


number="100"


whats the easiest way to conver this string into an int type

In C++ what is the easiest way to convert a string (std::string) to type int?
Use the standard library functions atoi (ascii to int), atof (float), or atol (long):





#include %26lt;stdlib.h%26gt;





int x = atoi("100");


float y = atof("100.1");


long z = atol("1000000");
Reply:Use streams:


string number= "100";


int x;


istringstream i(number);


if (i %26gt;%26gt; x)


cout%26lt;%26lt;x;


else


cout%26lt;%26lt;"Input not a number";





You have to include sstream for using this code. Now if you want to convert the number to float, just declare x as float and let the operator overloading do the rest.





I have provided you the code, now search net what does istringstream do and what magic can you perform with streams.
Reply:...


string s("999");


int n = atoi(s.c_str());
Reply:define it in a variable
Reply:I believe you could also simply "cast" the variable.


Here's the syntax: static_cast%26lt;type%26gt; (object)





static_cast%26lt;int%26gt;(x);





cout %26lt;%26lt; "x as integer" %26lt;%26lt; x %26lt;%26lt; endl;





I'm also pretty sure that there's no special include statements.





Hope that helps!





Rob


C++ codehow to input data into string like from file and than search for particular word in the string.?Thanks

if U have a file called f.txt for example U can make th following





freopen("f.txt","rt",stdin);





string s = "";





getline(cin,s); // this will read a line from the file





//now to search for a word use





s.strstr("Ur word"); // will return -1 in case the string is not found and the index of the start of the word otherwise





Regards,


Friday, July 31, 2009

How do u implement string functions using pointers in C?

i need a sample program involving strcpy n strcat

How do u implement string functions using pointers in C?
#include %26lt;stdio.h%26gt;


#include %26lt;string.h%26gt;





main() {


char* a = "hello ";//a is a pointer to a string "hello "


char* b = "world";//b is a pointer to a string "world"


char string1[strlen(a)+strlen(b)+1];//string1 is a pointer to a string of characters





strcpy(string1, a);//string1 now cantains a "hello " string


printf("%s\n", string1);





strcat(string1, b);//string1 now cantains hello world


printf("%s\n", string1);


}
Reply:The code example by jericbryledy is incorrect because no space has been allocated for string1 to contain the copied characters.





use malloc to provide space for the copied characters.





string1 = (char *)malloc(sizeof(char) * (strlen(a) + 1));


strcpy(string1, a);

sympathy flowers

The string of a piano that produces a middle c note vibrates with a frequency of 2.64x10(2) Hz.?

whats the speed of sound in air, if the sound waves produced by this string have a wavelength in air of 1.30m?

The string of a piano that produces a middle c note vibrates with a frequency of 2.64x10(2) Hz.?
Clue: what are the units of the Speed of sound? Meters/sec?





multiply the wavelentgh (m) by the frequency (sec^-1)





so 264 sec^-1 x 1.3 m = 343 m/s (1125 fps)





wer
Reply:beats the hell out of me. Ive been playing for 40 years. ( i have a failight and a babay grand a vox and a triton) been with bands for 25 years. Ive been considered a great touch and i can tune both the piano and figure out whats wrong electronically with my equipmetn. but i cant figure out why anyone would wantt o know this. except to waste his or her time. lol. seroiusly . just how much do you think the ear can hear? you remind me of the tone deaf singing. it just is chaotic and wrong. but if you make a better keyboard than whats out there. im all for it. ill play that too .though i cant imagine anyone noticing the difference. good luck!


The string of a piano that produces a middle "C" note vibrates with a frequency of 2.64x10(square root of 2)Hz

If the sound waves produced by this string have a wavelength in air of 1.30m, what is the speed of sound in air?

The string of a piano that produces a middle "C" note vibrates with a frequency of 2.64x10(square root of 2)Hz
The way that you typed the question has probably thrown everyone off. Middle C would be 264 Hz which can be written as 2.64 * 10². that is 'squared'; not 'square root'.





velocity = frequency * wavelength


= 264 * 1.30


= 343.2 metres per second.


How do you tune a six string electric guitar in standard C? (C F Bb Eb G C)?

DOES ANYBODY KNOW!!!!!?????

How do you tune a six string electric guitar in standard C? (C F Bb Eb G C)?
if you're dropping the tuning, you'll need heavier gauge strings to make up for the decreased tension. i suggest ernie ball 'not even slinky' strings, they're designed for lowered tunings.





other than that, you just tune to whatever you want. this is easiest, of course, with an electronic tuner.
Reply:correct, just tune everything two steps down. you get an extreamly heavy sound. alot of guitars can't handle the looseness of the stings and it sounds out of tune, or the strings rattle on the fretboard
Reply:calm down the easyest way is to buy an electric guitar tuner. i got one at guitar center for 20 bucks.
Reply:why don't you go and get a electric tuner? it's cheap.


Ca i get any saample code in C language for encryption and decryption of a string?

i wanna hav a sample code that gets a string as its input and uses some random numbers as the key values and encrypts the string. the same random numbers should be used to decrypt the string...

Ca i get any saample code in C language for encryption and decryption of a string?
take a look at this page:








simple encryption using table :


http://www.planet-source-code.com/vb/scr...
Reply:www.c++.com
Reply:www.programmersheaven.com

bridal flowers

C++: Cocatenating an int to the end of a string?

I need to know how to concatenate an int to a string, the simplist way possible.





Here is a snippet of my code (only elementCoefficients[index] is an int) :





string buildChemicalFormula(int elementCoefficients[])


{


string formula = "";


int index;


for(index = 0; index %26lt; numberOfElements; index++)


formula = formula + elements[index].chemicalSymbol + elementCoefficients[index];





size_t location;


size_t index1;


for(index1 = 0; index1 %26lt; formula.length(); index1++)


{


location = formula.find("0", 0);


if(location !=string::npos)


{


formula.erase(location-1, 2);


index1 = index1 - 2;


}


}





return formula;


}





When I try to create the new formula, the compiler outputs, " error C2676: binary '+' : 'std::basic_string%26lt;_Elem,_Traits,_Ax%26gt;' does not define this operator or a conversion to a type acceptable to the predefined operator".





I tried casting the ints to chars but didn't work.

C++: Cocatenating an int to the end of a string?
You should be able to use the itoa() function (integer to alpha). Here's more information. http://www.cplusplus.com/reference/clibr...
Reply:Do all your additions as int. When you are ready to print the string, use string + int and it will do automatic string conversion.


How do i use a string variable with input file handle in c++ ?

usually what i do is:





ifstream InputFile;


InputFile.open("sample.txt");





but instead of using a file name i want to use a string variable. This is what I have tried:





stream x = "sample.txt";


ifstream InputFile;


InputFile.open(x);





but it is not working ? anybody got suggestions ??

How do i use a string variable with input file handle in c++ ?
you want to use a string type, not stream. check documentation on the C++ STL libraries.





string input = //whatever is from the user


ifstream infile;


infile.open( input.c_str() );





...





"c_str()" just returns a char* buffer to methods that need it.
Reply:ok so what you need to do is declare a char array of string not a stream varaible








stream x ="blah blah" // wrong








char * x;





x = new char[10]; // or however long your characters are





// then





x = "text.txt"





ifstream InputFile;


InputFile.open(x);





// this should work also remeber to pick the iso mode for it good luck


How can we print a string(eg"College") on the screen in C without using any semi colon.?

WE have to write the program code to display the string "College" on the output screen without making the use of any semi colon in the code.PLZ HLP

How can we print a string(eg"College") on the screen in C without using any semi colon.?
put it in an if.





like


main()


{


if(printf("College"))


{


;


}


}


this should work
Reply:That, or you can use inline ASM to call the "printf" function:





__asm


{


push [edx], DWORD PTR "College"


call printf


}





I believe. It's been a while since I've implemented inline ASM (did it with my last game engine).


C++ Counting the number of words in a string?

How would you go about counting the number of words in a string and the number of occurences of each individual letter? Is there an easy way to do the counting or will I need to create like 26 different loops to do the counting?

C++ Counting the number of words in a string?
***note: the following code may not be completely accurate. it is meant to show a way to get the solution, but there may be bugs.





basically:





1) keep track of a word count using the # of spaces there are, not counting the 1st or last position.





2) keep track of a letter count, with the index of the array being the letter, and the contents being the # of occurances of that letter.





---





#include %26lt;stdio.h%26gt; /* standard in/output include file */


#include %26lt;string.h%26gt; /* include file for string functions */








#define MAXlength 50 /* max. length of test_string */








main()


{


char i, /* used as a counter */


ch, /* a temporary character */


strsz; /* the length of the string */





char test_string[MAXlength]; /* the string being dealt with */


char alpha_count[26]; /* the letter count (of 'aA'-'zZ') */


char word_count=0; /* the word count */





for(i=0;i%26lt;26;i++)


alpha_count[i]=0; /* set counts of letters to 0 */





/* --- insert code here for inputting the string from the user */





strsz=strlen(test_string); /*sets strsz to the lngth of the string */





for(i=0;i%26lt;strsz;i++) /* go through each character of the string */


{


if(test_string[i]==' ') /*if it's a space, and the space */


if((i%26gt;0)%26amp;%26amp;(i%26lt;(strsz-1)) /* is not at the beginning or end of */


word_count++; /* the string, increase the wordct. */





ch=toupper(test_string[i]); /* ch = uppercase of the letter */





if((ch%26gt;='A')%26amp;%26amp;(ch%26lt;='Z')) /* if it's a letter between 'A'-'Z' */


alpha_count[ch-'A']++; /* keep track of that letter */


}





printf("In '%s':\n,test_string);


printf("There are %d words.\n",word_count);


for(i=0;i%26lt;26;i++)


if(alpha_count[i]%26gt;0) /* don't show counts for letters that */


/* aren't there */


printf("There are %d '%c's\n",alpha_count[i],'a'+i);


}

wedding reception flowers

I need help completing this C code. Basically it asks user for input String and reverses it and changes cases.

#include %26lt;stdio.h%26gt;





char* strRev(char* line);


//your code here


char* str2Lower(char* line);





main(void){


//your code here


while(opt != 4){


printf("\n--------------------------...


printf("\nCST220 --- Assignment 2\n");


printf("Joe Smith XXX-YY-ZZZZ\n\n");


printf("Please choose the type operation\n");


printf("1. Reverse an string\n");


printf("2. Change an string to upper case\n");


printf("3. Change an string to lower case\n");


printf("4. End application (Exit)\n");


printf("Option: ");


scanf("%d", %26amp;opt);





if(opt != 4 %26amp;%26amp; (opt %26gt;= 1 %26amp;%26amp; opt %26lt;= 3)){


printf("\n\nPlease enter the string: ");


//your code here


if(opt == 1){


printf("\nThe reversed string is : %s", strRev(str));


}


else if(opt == 2){


printf("\nThe string in uppercase: %s", str2Upper(str));


}


else if(opt == 3){


printf("\nThe string in lowercase: %s", str2Lower(str));


}


}


}


}


char* strRev(char* line){


//your code here


return str2;


}





char* str2Upper(char* line){


//your code here


return str2;


}





char* str2Lower(char* line){


//your code here


return str2;


}

I need help completing this C code. Basically it asks user for input String and reverses it and changes cases.
#include %26lt;ctype.h%26gt;





char* strRev(char* line) {


char *str2, first;


str2 = line+strlen(line)-1;


while (str2%26gt;line) {


first = line;


*line = str2;


*str2 = first;


line++;


str2--;


}


return str2;


}





char* str2Upper(char* line) {


while( *line ) {


*line = toupper(*line);


line++;


}


return line;


}





char* str2Lower(char* line) {


while( *line ) {


*line = tolower(*line);


line++;


}


return line;


}


How can I grab user input using cin in C++ then take that and create a string with that name?

I am making a program for storing contact data for an assignment and need to know how I can make the string's name the same thing the user input. This is not for school :).

How can I grab user input using cin in C++ then take that and create a string with that name?
As far as I know there is no way of doing that directly, however, here is an idea of accomplishing a similar thing:





C++ has a data type (a thing to store data -- like an int, double, string, etc.) called a "hash map" (some people call it a "hash table", too, both are correct). It stores things in pairs of "key"s and "value"s. Some example keys and values for your program might be:





KEY (name) / VALUE (age):


Bob / 16


Sally / 17


Bill / 40





To create a hash table, first include the proper library for it (#include %26lt;map%26gt; where you include everything else such as iostream or string, etc.), and then somewhere in your program, declare it in the following way:





map%26lt;string, int%26gt; my_hash_map;





This creates a new map variable named "my_hash_map" which has strings for keys and ints for values (as in our example with names and ages).





To add a person and their age to the map, do the following:





my_hash_map["Bob"] = 16;


my_hash_map["Sally"] = 17;


my_hash_map["Bill"] = 40;





When you want to look up someone's age, you can do the following (prints "Bob's age is 16; Sally's age is 17; Bill's age is 40"):





cout %26lt;%26lt; "Bob's age is " %26lt;%26lt; my_hash_map["Bob"] %26lt;%26lt; "; Sally's age is " %26lt;%26lt; my_hash_map["Sally"] %26lt;%26lt; "; Bill's age is " %26lt;%26lt; my_hash_map["Bill"] %26lt;%26lt; endl;





You can find more information on hash maps including how to delete items at it's C++ Reference page: http://www.cplusplus.com/reference/stl/m... .


How Do I Get The Class Location In C#, Dont Know How To Formulate Connection String?

In JAVA I used to use a class which told me where the class was located. I'm trying to tell the application that the database is in the solution but how do i do it?





I've got an OLEDB database, but i dont know how to formulate the connection string. The database is inside the Visual Studio solution but I dont know how to tell it that.





Please help...

How Do I Get The Class Location In C#, Dont Know How To Formulate Connection String?
Right click on your solution explorer and select properties. Go to the settings tab, type a name for a new setting (like DatabaseConnectionString) and select [Connection String] as the type. A wizard will popup allowing you to select a database; select your database. From now on, you can access this connection string using the Settings namespace, it would be:





Settings.Default.DatabaseConnectionStr...





I find this method much easier for doing this than remembering how to formulate the connection string. Adding the DB to your application solution really doesn't do anything for connecting to it.
Reply:OLEDB won't give you anything about the connectionstring. You dont really need to know where it is located.


I am using MYSQL database and when installed that MYSQL connector I just added it to each page i needed to work with MYSQL like this:





using MYSQL.data;





this way I get all the classes I need to connect and work with my database.


I hope this helps you


Could anyone give me a C program to find substring from a string?

I kindly request U to give me the C program if U have,its Urgent.


I tried my level best but i dint get the result for some substring,


I Cant find out the logical error.So please help me.


Thanks in advance

Could anyone give me a C program to find substring from a string?
just use strstr.





Look at an open source copy of the code for strstr

flowers gifts

I want a program whith c++ (it should get a string a=[12 3;4 5.5] and put the numbers in a matrix )?

it should understand size of matrix and put numbers in it,s arrey

I want a program whith c++ (it should get a string a=[12 3;4 5.5] and put the numbers in a matrix )?
I didn't find out what exactly you want but if you mean that you must enter a string like [12,13,25.5,123,12] and the program puts them into a array it's very easy. else it's not the case you can mail me and I'll tell you the soloution.


NOTE: I didn't test the program cuz i'm right now at cofenet and it might not work correctly and depending on your compiler you may change some of lines. I recommend Microsoft Visual Studion 6 or Borland C++ for you








//this programs wrote in a old style and


//works with many compilers


#include %26lt;iostream.h%26gt;


#include %26lt;string.h%26gt;


#include %26lt;stdlib.h%26gt;


#include %26lt;math.h%26gt;





void main()


{


double *array;


char string[255], *temp,*ptr, *tptr, number[10]; //or more


cout %26lt;%26lt; "Enter your desigered string: " %26lt;%26lt;endl;


cin.getline(string, 255);


temp = new char [strlen(string) + 1];


strcpy(temp , string);


int size;


ptr = strtok(temp, ',');


for (size = 1; ptr != NULL; size++)


ptr = strtok(NULL, ',');


array = new double [++size];


int i = 0;


ptr = strtok(string, ',');


strncpy(number, string + 1, ptr - string - 1); //ignore [


number[ptr - string] = '\0';


array [i] = atof(number);


tptr = ptr;


ptr = strtok(NULL, ',');


while (ptr != NULL)


{


strncpy(number, tptr + 1, ptr - tptr - 1);


number[ptr - tptr] = '\0';


array [++i] = atof(number);


tptr = ptr;


ptr = strtok(NULL, ',');


}


for (int j = 0; j %26lt; size; j++)


cout %26lt;%26lt; "The array [" %26lt;%26lt; j %26lt;%26lt; "] = " %26lt;%26lt; array[j] %26lt;%26lt; endl;


}