Sunday 15 September 2013

C, issue with asigning a value through a pointer in a function -


OK, I've written a small function to convert any capitals into a string in a small font I am learning from C

Everything works well in addition to specifying a value in 'four' through an indicator.
There is a code and everything is compiled properly, but I get this runtime error "Uncountable Fake Transfer Protocol Version% d" This is why I try and print four colors that are medium of pointer Changed from

  #include & lt; Stdlib.h & gt; # Include & lt; Stdio.h & gt; / * ---------------------------------------------- Converter uppercase Characters for lowercase ---------------------------------------------- * / Empty lowercase (four * address, four text 2) {// used in loop int coop; // text2Copy int inctwo = 0 used as an indicator for; // loop int length = used in string (text 2); // Lesson text used to make the active character copy in text [length]; (Text 2 [Ink]> = 'A' & amp; amp; text2 [inc] & lt; = for 'z' (inc = 0; inc & lt; = length; inc ++) {// Basicaly}} {// I plus 32 because 32 numbers in each letter 'ASCII' are far away, so the capital turns into lowercase text. [Inctwo] = text2 [inc] + 32; // Add one to help with inducting inctavon ++; } // If a character is not a capital then {text2Copy [inctwo] = text2 [inc]; Inctwo ++; }} // * address = "sdafsdf"; // & lt; - Does it work !!! * Address = text2Copy; // WHY DOESN "T WORK?} Int main () {// Just string I am using. Char * text =" to reduce the convergent capitals "; // String the original printf ("% s \ n", text) to print; Lowercase (and lesson, lesson); // This is where I have to print the value printf ("% s \ n", text) from the function. ; 0;}   

If you can help me, I would appreciate it very much, I am really confused and a little annoyed why this will not work. Just request it I hope I've already done enough.

Thank you, Jake. /// /////////// Edit ///////////////////////////////////// //////////////////
OK I have used all thanks to you with your suggestions: d. And now it works apart from strange bugs which I do not know how to fix it.
Everything changes to the character of a lower case than the first letter.
What happens now - & gt; "At the same time reversing capitals" I do not know why FIR character is doing this? Anythoughts?

Here's the new code.

  #include & lt; Stdlib.h & gt; # Include & lt; Stdio.h & gt; / * ---------------------------------------------- Converter uppercase Characters for lowercase ---------------------------------------------- * / Empty lowercase (four * address, four text 2 []) {// used for loop int coop; // loop int length = used in string (text 2); (Text 2 [Ink]> = 'A' & amp; amp; text2 [inc] & lt; = for 'z' (inc = 0; inc & lt; = length; inc ++) {// Basicaly}) {// I plus 32 because each letter is a distant number in 32 'ASCII', so convert capital to lowercase text 2 [Inc] + = 32; // Add one to help with inducting inctavon ++; } // If the character is not a capital and the other {inctwo ++; }} * Address = Lesson 2; } Int main () {// Just the string I will be using Four lessons [] = "less case for capitals capitals"; // Print the string to show the original printfile ("% s \ n", text); Lowercase (& text, text); // This is where I have to print the value from the function print ("% s \ n", text); Return 0; }    

There are many problems with you that the first is that your program should not be compiled too Because you pass your kind of work incorrectly. The second thing is that you try to modify a literal (and therefore continuous) string.

For the second part, you can solve it easily by using an array instead:

  four text [] = "less case for convert capitals ";   

You also try to "return" to a pointer in the local variable, and it will become undefined behavior because the local variable, well, local. A function, which they return the captured memory, will be reused with other functions.

For the actual conversion function, it can be simplified too many by your effort: Lowercase lower (four * less) {While (* text! = '\ 0') * text = tool (* text); }

No comments:

Post a Comment