[Solved] Unclear about return value of a void function in C [closed]

The result in this situation is based on whats on top of the stack when test() is returned. The behaviour is undefined. You should compile your code with warnings enabled: gcc main.c -Wall Also, altering your argv pointer is a bit dirty. De-referencing argv directly communicates your intentions in a clear way: printf(“\n%d\n”, test(atoi(*++argv), 2)); … Read more

[Solved] Start child process process inside parent process

Is it possible to start a child process inside same address space? I would like to access any exported function localy. No, it’s not possible. The operating system creates a new address space for each process, that is protected to be accessed from other processes. Use threads instead. 9 solved Start child process process inside … Read more

[Solved] Read Key in Wpf [closed]

If you have access to XAML, try the OnKeyDownHandler method. XAML: <StackPanel> <TextBlock Width=”300″ Height=”20″> Type some text into the TextBox and press the Enter key. </TextBlock> <TextBox Width=”300″ Height=”30″ Name=”textBox1″ KeyDown=”OnKeyDownHandler”/> <TextBlock Width=”300″ Height=”100″ Name=”textBlock1″/> </StackPanel> C#: private void OnKeyDownHandler(object sender, KeyEventArgs e) { if (e.Key == Key.Return) { textBlock1.Text = “You Entered: ” … Read more

[Solved] Sort words and then the sentence including digits and characters in Shell scripting or perl scripting [closed]

The algorithm to sort this problem is simple, just like you said in your question description, sort characters in each word first, then sort these sorted-word again. Like this: $ echo heya64 this is21 a good89 day91 | perl -anE ‘say(join ” “, sort(map { join “”, sort split // } @F))’ 12is 19ady 46aehy … Read more

[Solved] How to create a program that counts number of works and characters in a line in C++ WITHOUT using #include [closed]

For counting characters, you can read the characters in one-by-one (see istream::get()), maintaining a count until you hit an end-of-sentence marker. That means something like (pseudo-code, since only classwork tends to have these bizarre limitations and you’ll learn very little if we do the work for you): # Initial count. set charCount to 0 # … Read more

[Solved] How do you make a c++ program search for a string? [closed]

First open an ifstream to open your file then check for the string: #include <iostream> #include <fstream> #include <string> using namespace std; int main () { string line; ifstream myfile (“example.txt”); if (myfile.is_open()) { while ( getline (myfile,line) ) { if(line.find(“the string to find”) != string::npos) { //line found, do something } } myfile.close(); } … Read more

[Solved] Expected primarly expression before ]? (C++)

The error message tells you that an expression is expected at a certain point in your code: calcNumbers(myArr[missing expression here ], type); Why is that? Because operator[] takes an argument (traditionally an index), as in myArr[1]. No argument, no compile. Note that this error occurs when you are using myArr. You have other places where … Read more

[Solved] Difference between std::string [] operator and at()

Your second program is malformed. It’s not using std::string::operator[] at all. string * ps = new string(str); ps[0] = ‘n’; Not only does std::string support the [] operator, every pointer to a type also supports the [] operator. It’s how C style arrays work, and it’s what you’re doing in the code above. ps isn’t … Read more

[Solved] How to dynamically allocate memory in 2D array and store values? [closed]

As i said problem is in scanning N and M variables. Change scanf(“%d %d”,&N,&N); to scanf(“%d”,&N); scanf(“%d”,&M); and you are fine. Problem was you were reading N twice while didnt read an M which was used uninitialized. Non-static variables (local variables) are indeterminate. Reading them prior to assigning a value results in undefined behavior. You … Read more