c-strings

Reverse a string without strtok in C

谁说胖子不能爱 提交于 2021-02-08 11:15:23
问题 Working on a program that uses RPN (Reverse Polish Notation). I have a function that reverses all the words of string without using strtok or triggering printf (unlike all the solutions found online and here). The function actually works partially as it prints all the words of a given string except the last one and I need help figuring out what's going on. char *extract(char s[]) { if (s[0] == '\0') return NULL; int i = 0; char *p = NULL; while (s[i] != '\0') { if (s[i] == ' ') p = s + i; i++

Reverse a string without strtok in C

给你一囗甜甜゛ 提交于 2021-02-08 11:13:01
问题 Working on a program that uses RPN (Reverse Polish Notation). I have a function that reverses all the words of string without using strtok or triggering printf (unlike all the solutions found online and here). The function actually works partially as it prints all the words of a given string except the last one and I need help figuring out what's going on. char *extract(char s[]) { if (s[0] == '\0') return NULL; int i = 0; char *p = NULL; while (s[i] != '\0') { if (s[i] == ' ') p = s + i; i++

Debug Assertation Failed c >= -1 && c <= 255

≡放荡痞女 提交于 2021-02-08 10:51:12
问题 I am having a difficult time understanding this runtime error with my code. This was an assignment for my class that I thought would be easy, but something strange is gong on. I have posted my code below. The prompt for this assignment was to create a program that asks the user to enter to enter some words, then it should output how many words there are. I have had a friend run the program and it worked, however, whenever I try to run it I get this runtime error. [ http://imgur.com/FcdN3zK ]

Debug Assertation Failed c >= -1 && c <= 255

拥有回忆 提交于 2021-02-08 10:49:45
问题 I am having a difficult time understanding this runtime error with my code. This was an assignment for my class that I thought would be easy, but something strange is gong on. I have posted my code below. The prompt for this assignment was to create a program that asks the user to enter to enter some words, then it should output how many words there are. I have had a friend run the program and it worked, however, whenever I try to run it I get this runtime error. [ http://imgur.com/FcdN3zK ]

Modifying a String (char array) [closed]

老子叫甜甜 提交于 2021-01-28 03:23:00
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 11 months ago . Improve this question I am trying to modify a string in C language char signal_cat[8]; if (k == 1) { strcpy_s(signal_cat, "HPHA",6); //why cant I change char array (string) values??? } else if (k == 2) { strcpy_s(signal_cat, "Normal",6); } printf("Original signal category: %s \n", signal_cat); When

Modifying a String (char array) [closed]

我的梦境 提交于 2021-01-28 02:12:14
问题 Closed. This question needs debugging details. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed 11 months ago . Improve this question I am trying to modify a string in C language char signal_cat[8]; if (k == 1) { strcpy_s(signal_cat, "HPHA",6); //why cant I change char array (string) values??? } else if (k == 2) { strcpy_s(signal_cat, "Normal",6); } printf("Original signal category: %s \n", signal_cat); When

C: Printing from char array produces erroneous characters

≯℡__Kan透↙ 提交于 2021-01-27 19:15:51
问题 Solutions for K. N. King's C Programming: A Modern Approach, 2nd Edition , Chapter 8, Programming Project 14, produces different outputs both correct and incorrect. Examples shown below: Reversal of sentence: you can't swallow a cage can you? Reversal of sentence: you can't swallow a cage can you�(�? Reversal of sentence: you can't swallow a cage can you��x�? Reversal of sentence: you can't swallow a cage can you�Ց�? As shown by the example input, correct output should be: Enter a sentence:

JNI GetByteArrayElements () Error

雨燕双飞 提交于 2021-01-27 07:56:28
问题 I'm new in JNI so I'm not familiar in JNI and also English. My JNI project is a simple File reading and writing. File reading in Java and passing the byte array to C API the write it into file using C. My source code: Java code is : public class FileIO { static { System.loadLibrary("FileIO"); } private native void writeFile(byte[] msg); public static void main(String[] args) throws IOException { byte[] array = Files.readAllBytes(new File("PtFBWCTn.mp3").toPath()); // System.out.println(array

JNI GetByteArrayElements () Error

空扰寡人 提交于 2021-01-27 07:53:51
问题 I'm new in JNI so I'm not familiar in JNI and also English. My JNI project is a simple File reading and writing. File reading in Java and passing the byte array to C API the write it into file using C. My source code: Java code is : public class FileIO { static { System.loadLibrary("FileIO"); } private native void writeFile(byte[] msg); public static void main(String[] args) throws IOException { byte[] array = Files.readAllBytes(new File("PtFBWCTn.mp3").toPath()); // System.out.println(array