Monday, May 24, 2010

Which strings are best for the G and C Strings on a Cello?

My teacher recommends me to switch the lower strings on my cello because it doesn't match the sound well. I currently have Helicore. Which is the best or a good one to choose from?

Which strings are best for the G and C Strings on a Cello?
Personally I think Helicore strings are the best, but if your teacher wants youto get new strings you should try gettind Dominant strings





hope this helps


Can you help me a problem in arrays of strings in C?

How can I copy a string (array of character) to an array of string such as:





char text[a][b];





wherein a is the index number of the array and b is the max length of array of characters that can be stored in the array..





For example I have an array of characters "char word[20];"


How can I store it to an array of strings "char text[99][20];"??





Please help.. And thanks..

Can you help me a problem in arrays of strings in C?
you can use the strcpy() function.





strcpy(text[99], word);





or:


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


{


text[99][a] = word[a];


}





both will work.
Reply:Yes it is possible!!


Wat U need to do is that for example


let








char word[5]={'a','b','c','d','e'};


char test[20][10];


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


{ {test[p][q]=word[i];


q++;}


if(q==10)p++;


}








Ok Gud LC Bye
Reply:for (int x=0; x%26lt;20; x++)


{


text[0][x] = word[x];


}





// This will copy the char array word into the first row in text.


// word is a one dimensional array.


// text is a two dimensional one.


Anybody genius in c++ programming .This question is specially to them........?

Describe about c-strings in c++ programming .mention its functions


and also advantages of using these strings while programming....

Anybody genius in c++ programming .This question is specially to them........?
Hope this will help u


http://www.cprogramming.com/tutorial/les...
Reply:What are c-strings?
Reply:You don't need to be a genius to answer that.





Don't be so specific like that - give _everyone_ an opportunity to help you. Otherwise it's called "looking a gift horse in the mouth".





Rawlyn.
Reply:yes indeed

baseball cards

How to check for anagrams in C++?

I need a program to check two entered strings of text and see if the strings entered are anagrams, disregarding the case of the letters, and ignoring spaces (i.e. "Mother in Law" and "Woman Hitler" are anagrams). The strings won't be any longer than 500 characters.





I can't figure out what to do with this because it has to use arrays, which I have never been good with, and the emphasis is supposed to be on use of c strings.





I do know that it essentially needs to do this: change the case of the two strings and remove anything that isn't a letter, then sort the letters, and finally determine if they are the same (are they anagrams?).





I'm trying to keep this "simple." Can anyone help me with a program that does this? Thanks SO MUCH in advance!

How to check for anagrams in C++?
Well, in programming, we always try to get a clear problem definition and logical solution before we start coding.





Oh wait...I was thinking of a palindrome...





Answering questions for people is like programming. We should think 1st. :-)





Yes, sorting is a good idea. And so is changing case....changing case before the sort will enable a clean sort...





1 - Change both strings to lowercase with _strlwr( char *string );





2 - sort both strings... see qsort() for a cheap easy solution that your compiler probably already has. All mine have had qsort().





3 - kill whitespace. You mite need to build a function for this...but qsort should have moved all the whitespace to the end (or begining) which makes it easier (especially if at end).


- You can kill trailing whitespace very easily by putting a null '\0' at the very first instance of white space, if whitespace is at the end, like so:


for(ii=0; ii%26lt; strlen(string); ii++)


if(string[ii] == ' ') // a space?


{


string[ii] = '\0'; ///kill it and cap the string


break; // we're done


}








4 - compare the two strings with strcmp(). If they match, they're anagrams





That's our flow plan and function ID.
Reply:so its a "string compare" your doing ? ;-)





on the first one, u could have a pointer.. basically u check a letter against the second string...





you either have true / false... you need a recurssive loop that checks till end of line / null





it will either return TRUE and exit that loop.. then get ++ the string1 .. and repeat scanning string2..





if it returns false, after the end of string2... obviously they aren't the same..





i would have an array or struct, with a flag in for each character.. 1 exists.. 0 doesn't exsist





then print results.. eg..





found =


not same letters =





and no i'm not gonna do the code, u've had enough clues to do ya own homework =)
Reply:It is not that easy. May be you can contact a C++ expert at websites like http://askexpert.info/


How do i know if my bass is tuned to C correctly?

i just tuned my low e string to C so it would sound better when playing SOAD seeing as how most of there songs are on only one or two strings.


its tuned to C but its really loose and buzzes off the frets so im not sure if its right

How do i know if my bass is tuned to C correctly?
If you're going to tune down that far, you'll need thicker strings, and possibly a neck tweak.


Java equivalent to System.Text.StringBuilder in C#?

I want to build a very large string from lots and lots of small strings. In C# I would use System.Text.StringBuilder without hesitation. At present I am using java.io.StringWriter, but I am concerned that it may not be efficient enough? Is there a better option? MUST be FAST! Thanks in advance.

Java equivalent to System.Text.StringBuilder in C#?
That is not what StringWriter is for. StringWriter is a character-based output stream that writes the bytes to memory.





Use java.lang.StringBuilder. It was added in Java 5 (JDK 1.5). It is similar to java.lang.StringBuffer, but without the synchronization. So, if you plan on designing your program such that only one thread will be using it, use the StringBuilder.


C - How do I save data in a text file?

I have made a maze game in C and am stuck on how to get a user name and save the username and score on a text file. I don't know much about string in C except that "it is an array of characters". I know a user name will need to be string so I am using this:





char username[3];


scanf("%s", username);





I am assuming the variable 'username' will be saved to a file but I do not know how to do this. Any ideas?

C - How do I save data in a text file?
You need the following basic steps:





FILE *fp; //create a file pointer


fp = fopen("file","w"); //open "file" for writing "w"





//check if the file was opened without errors


if(fp==NULL) {


printf("\nCould not open file.. aborting!!");


exit(1);


}





//write to file - you have a number of options here - read more about the functions to suit the formatting and data you need to write to file - one example below:





fprintf(fp, "%s %d", username, score)





fclose(fp); //close the file pointer once you are done writing to the file.
Reply:Use fprintf() function or fwrite() function. Refer the page given below...

artificial flowers

Question about strings in C?

When reading in strings, how can I include spaces in the string?





What I mean is that, normally, you'd need something like





scanf("%s%s%s", %26amp;str[0], %26amp;str[1], %26amp;str[2])





to take something like





"one two three"





and read it in as three strings.





How can I read in "one two three" as one string? That is, without the program assuming that spaces are breaks between strings?

Question about strings in C?
You can use scanf as below to read until end of line.





scanf("%[^\n]",%26amp;str[0]);





That should work.





All the best !
Reply:fgets gets the entire line.


If you want to read in more than a line you must use fread.


Then parse it manually.





P.S.


I personally don't use scanf to read in strings from stdin because it's a potential buffer overflow(security risk).


If you are going to use scanf specify the field width %10s or use %as to allocate the string.ualifier is present, the next pointer must be a pointer to


wchar_t, in


C programming question?

Given the following declarations:


char a[ ] = "abc", *p = "def";





What is the effect of the following statement?





p=a





a. It copies the string "abc" into string p





b. It changes p to point to string "abc"





c. It copies the first character of a ton the first character of p





d. It generates an error

C programming question?
haha cheater.





ya D) is looking good.
Reply:Genrates Error
Reply:b.


p is a pointer to char.


The name of the array a is also a pointer to char.
Reply:b. p will point to a which contains "abc".
Reply:The answer is b.





I just wrote a little code to do it, although I should have been smart and just looked at K%26amp;R.
Reply:p will then point to the first position of a, it won't point to the whole string but you can use pointer arithmatic to get the rest of the string. So - E. none of the above.
Reply:Usually it would be b. Because you replaced the adress the pointer points at. But i am not quite sure you can declare a pointer on a string constant (*p="def") - it would probably generate an error.


How do you reverse a string? In other words if I have "It is hot today", I want to get "today hot is It".

How do you reverse a string in C/C++?

How do you reverse a string? In other words if I have "It is hot today", I want to get "today hot is It".
hmmm, sounds like you should read your text, perhaps post some code and then ask for some help. this might lead you in the right way:





#include%26lt;iostream%26gt;


#include%26lt;string%26gt;





int main()


{


using namespace std;





string txt;





cout%26lt;%26lt;"Enter anything, come on, anything...\n";


getline(cin,txt);


string::iterator end = txt.end( ) - 1;





for( ; end != txt.begin( ) - 1; end--)


{


cout %26lt;%26lt; *end;


}





cout %26lt;%26lt; endl;


system("pause");


return 0 ;


}
Reply:just reverse the string i guess


and in arrays if it from 1 to 5 it will count 12345 but if u reverse it as 5 to 1 , it will show 54321


good luck
Reply:Technically you are not reversing a string. You are reversing a subset of items inside a string.





So you would have to create an array of strings. Parse the contents of your original string by some separator, such as a space.





Then just reverse loop through the array of strings.


How can i manipulate string to know whether the substring is contained in the string?

how can i manipulate string in c++ to know whether the substring is contained or have a pattern in the string?


but,without using strcmp.

How can i manipulate string to know whether the substring is contained in the string?
Saw this yesterday...
Reply:in C/ C++ i would go for the library function strstr();


in JAVA, str.contains(str1) would do the trick, where str is the string in which str1 has to be searched

800flowers.com

C++ Pointers to Strings?

I'm writing a C++ program in 3 separate files. Here's some of the pseudocode:





Rectangle.h


_________





...


private *char name;





rectangle


deconstructor


getName


setName


draw











Rectangle.cpp


_________





default constructor: name = "bleh";


constructor: [asks the user to enter a name and prints it back]


draw: [print name]


getName: gets the name


setName: modifies the name


deconstructor: deletes the string








TestRectangle.cpp


___________





...


Rectangle r1;


r1.draw();


r1.getName();





How do I... er... do all of this? I have to allocate memory for the string using the new keyword.


I've been trying to look this stuff up but can't seem to find anything helpful.

C++ Pointers to Strings?
"Algorithms + Data Structures = Programs", by Wirth.





You evidently learned C++ before you learned programming. Take a break and learn programming now.


C++: Converting unsigned int to int?

I want to perform a little calculation using a length of a string in C++. Im new to this. :(





Example:





string myString = "Hello";


int myCalc;





myCalc = 100-(myString.Length); // is this correct? I want to minus string's length from 100.





But it gives compile error: "error C2440: 'type cast' : cannot convert from 'unsigned int (__thiscall std::basic_string%26lt;char,struct std::char_traits%26lt;char%26gt;,class std::allocator%26lt;char%26gt; %26gt;::*' to 'int'


Conversion is a valid standard conversion, which can be performed implicitly or by use of static_cast, C-style cast or function-style cast"








I tried casting with "int(myString.Length)" but it doesnt work. :(





Please help me out.

C++: Converting unsigned int to int?
length in standard C++ is a function. You need to call it using myString.length()





There shouldn't be a problem putting an unsigned int into an int variable. The compiler is probably complaining that you're trying to convert a function (length) into an int, since you left out the parentheses.
Reply:thanx others too! Report It

Reply:I haven't learned C++ yet( opertune word there is yet) but in Visual Basic when you want to utilize a Str varialble and a Int variable you must declare them seperately and then use the


Val() option to translate. this will allow you to set arguments for converting string varialbes to integer or vise versa.





example intcalc = Val(strCalc)





dont know if that works or if it is even support in C++ but it never hurts to take a look.
Reply:try making myCalc unsigned...


unsigned int myCalc...might work!





Additional details(added later on)


man o man


1) there is nothing that is Length it is length (C++ is case sensitive)


2) it is function so correct call would be myString.length()





then it runs on gcc compiler





best of luck!
Reply:C++ I managed to avoid thus far, but I think AM post's is correct. Make myCalc an unsigned int.





I don't know how many bytes an int type in C++ is, but for the sake of illustration, lets say it is 1 byte.





An unsigned int can take on the values 0..255


Int can be -128..0..127.





Obviously you cannot stuff an insigned int into an int. The type cast can't help you because you run into the same problem. It can't map the silly things.





-Dio
Reply:You want to cast using "(unsigned int)", like this:





myCalc = 100-(unsigned int) (myString.Length);





Now, if you change the declaration of myCalc to





unsigned int myCalc;





you could avoid the whole issue. However, if the string length is greater than 100, you'll get a very large number as a result, which could be bad.


B.C. Rich Warlock strings help...?

Alright, so as you saw I have a B.C. Rich Bronze Series Warlock guitar (red). I got it a little while ago, and just today one of my strings broke. It was the e (thinnest) string. I need help with getting it replaced. I'm a beginner and this is my first electric guitar. I read online that some some strings break real easily on it, so I need a kind of string that won't =]. Can I do it by myself or should I give it to the store? If I do it myself (which I'll probably get the previous owner of the guitar to do it for me) what kind of strings should I buy? Name, place available, and price please. Thanks a lot guys!!!





P.S. I know this is silly but I have no idea what I'm doing, except for playing, with a guitar. =D

B.C. Rich Warlock strings help...?
ok heres the deal...


you can buy new strings and do it yourself its really easy


you want to get a first string "e" with the gauge size being "9" %26lt;---IMPORTANT! also look into a stringing tool. they're really cheap and worth the money. they make stringing a guitar really easy instead of turning the peg by hand (hand cramps suck).





BUT! Heres The Problem. You Need To Find The Same Brand That Comes On Your Guitar. Obviously B.C. Rich Strings.


They're Strings Tend To Sound Different Than Others. You're Best Option To Get The Best Sound Out Of Your Guitar Is To Either Buy A New B.C. Rich "E" String Or Buy A Whole New Package Of Strings Which Really Isnt A Bad Idea.


It Is Good To Change Your Strings Every Once In A While





Good Brands To Look For Would Be "Ernie Ball", "Elixir", And Of Course B.C. Rich. Remember To Get 9 gauge Strings
Reply:ernie ball bad they will break blue steel are great but there steel they will wear your frets faster if you realy want some good strings elixer they are 13 dollars tho but great tone Report It



C/C++ pointers as strings?

I am a relative novice at C++, and I am trying to write a stack class that holds lines of text. I need to hold everything in pointers because I don't know the sizes of things, and I have one question. Do you have to use new or malloc to allocate adequate memory to a pointer, or will it act intelligently? For example will:





char *string = new char;


std::cin %26gt;%26gt; string;





instead of:





char *string = new char[100];


std::cin %26gt;%26gt; string;





possibly cause it to segfault or corrupt other variables (I know it will at least hold the data)? I haven't had that happen before, but just to make sure...

C/C++ pointers as strings?
the above answer is excellent advice (or below, the guy who said use strings). Do NOT use arrays of chars. You risk buffer overflow and if that happens your program will be entirely compromised. A buffer overflow in your case would be when you had a char array of say 100, but the user entered a line of text with over 100 chars. After 100, you're program will be writing char values to memory that is outside of your array and could be other variables, return values, etc.
Reply:Hi,


If u r using char pointers then dont worry about the size of string, to be saved in that char pointer.





Poiter reuires 2 bytes only. Char pointer holds only the address of the string not the string itself.





so


char *p;


p="a";


or


p="abcdefghijklmnopqrstuvwxyz";





so either u save a character or a string of any length, doesnt matter.
Reply:These examples do not make sense to me. 'char' is a primitive type and not a class.





This is how I would declare string. It is a simple array of char big enough for what you will use it for.





char string[100];


std::cin %26gt;%26gt; string;





If you use the C++ string class then it will resize and do clever things automatically. Hurrah!





#include %26lt;string%26gt;





string mystring;


std::cin %26gt;%26gt; mystring;


std::cout %26lt;%26lt; mystring;

wildflower

I need add 2 string in VB 6.0?

Dim a as string


Dim b as string


Dim c as string


a="HI"


b=" "" "


c=a+b


How i show c="HI"


I can not add "" (this string). Pls help me

I need add 2 string in VB 6.0?
Dim a as String


Dim b as String


Dim c as String


a = "HI"


b = "!"


c = a %26amp; b





would make c = HI!





Is that what you're asking?


What is the c++ code runnable in dev c++ developmental tool, for this output????

what is the c++ code runnable in dev c++ developmental too, for this output????


it will accept a string and creates a figure,, like in the following:





(it will be like this if the number of amount of string is an even number)





enter string: ccss


c c


c


s


s s





(it will be like this if the number of amount of string is an odd number)








enter string: table


t t t


a a


b


l l


e e e








(note: it should be 3 strings to be accepted as input(string) in this program)

What is the c++ code runnable in dev c++ developmental tool, for this output????
what he heck is this? where did you find it


C++ Programmers!! help!!?

there's an error in this code... can you help me repair it?!








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


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


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


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





void initval();





int chars[255];





int main()


{


FILE *file_r;


int ferr = 0, i;


char filename[50];


while (ferr == 0)


{


system("cls");


printf("Enter file name: ");


gets(filename);


file_r = fopen(filename, "r");


if (file_r == 0)


{


printf("Error! File does not exist!");


getch();


}


else


{


ferr = 1;


}


}


char *r;


char c, ctr = 0;





while ((c = getc(file_r)) != EOF)


{


ctr++;


}





fclose(file_r);


file_r = fopen(filename, "r");





char string[ctr];





i = -1;


while ((c = getc(file_r)) != EOF)


{


i++;


string[i] = c;


}





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





printf("\n\n%s\n\n", strrev(string));





//tig-ihap





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


{


chars[string[i]]++;


}





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


{


if (chars[i] != 0)


{


printf("%c = %d\n", i, chars[i]);


}


}





getch();





fclose(file_r);


return 0;


}





void initval()


{


int i;


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


{


chars[i] = 0;


}


}

C++ Programmers!! help!!?
do this:





char [] string = new char [ctr];








and don't forget





delete [] string





at the end to free up the memory
Reply:from the code you provided i copy and paste it on my system and i recieved no error messages and the program ran fine most likely it has to do with your compiler in my unix based system it didn't recongize the conio.h header file try using a different compiler
Reply:you cant declare a char string that way (char string[ctr]). the length of the string has to be a constant size such as "char string[20];". as the other person said, you could also do this "char [] string = new char [ctr];"
Reply:The code you're using isn't C++, it's just C. It'd help if you listed the error.


What is the source code to sort a linked list in C? Strings are what to be sorted.?

It's a linked list of structures with strings. The whole program is like a directory. The string is the name. We must sort it out alphabetically as we enter the data. Kind of frustrating that I have to do ask this.

What is the source code to sort a linked list in C? Strings are what to be sorted.?
Instead of sorting the list after entering the node, you must sort it while inserting the node. Whenever you add a new node compare it with all the nodes already present in the linked list and insert it accordingly. The "head" pointer points to the first node and the successive "next" pointers point to the nodes that are (alphabetically) smaller than the current node.





This is just kind of a rough algorithm. Try to code it, hope you got it.
Reply:When creating linked lists I make sure a prototypical comparison method exists. This method is generally customized for each type making use of the template.





Like strcmp() the method is intended to return less than zero if the left operand is less than the right, zero if equal, and greater than zero if the left operand is greater than the right.





Two sorting methods are provided (as overloads of each other.) One is the general sort which will do the basic ascending or descending values of the list. The other accepts a function pointer that allows for a custom sorting algorithm.





An example of a custom sorting algorithm is a randomizer; it simply returns one of the three expected returns at random. :-)
Reply:That is not easy. May be you can contact a C expert at websites like http://askexpert.info/

tarot cards

How do you dump hex to a file using c++?

I have a c++ string of data. I want to dump this data as hex to a file. I'm not talking about just converting each character to its hex representation. I want to actually dump binary to a file.

How do you dump hex to a file using c++?
ofstream outf;


outf.open("dump", ios::binary);


ios::binary informs open that no translation of data to file is to be performed.


Basically, you write '\n' to a data file in text, it translates to '\r\n'


'\r' by itself does not get translated.


outf.write(data, data_size);


outf.close();