Your code works based on the following conditions:
If the left parenthesis follows 'if' (no spaces in between), such as if(, but it will not work for if (.
If you are not using comments in your...
Type: Posts; User: rassul
Your code works based on the following conditions:
If the left parenthesis follows 'if' (no spaces in between), such as if(, but it will not work for if (.
If you are not using comments in your...
while(finished == 0){
printf(" \n Enter your desired operation (+, -, *, / or exit): ");
while((o = getchar()) != '\n' && o != EOF); // clear input buffer
scanf("%c", &o);...
laserlight is right, we should use fflush function for output, therefore instead of using fflush we can clear the input buffer like:
while((O = getchar()) != '\n' && O != EOF);
and then call...
You will need to read about scanf and getchar functions. Here is what is happening, let's focus on second scanf:
scanf("%d", &B2);
Suppose you type 5 and hit the enter key, now scanf takes only...
Thank you Salem and others for helping. My question was answered by you wonderful/helpful people. Case closed.
char (*lines)[5];
lines = malloc(10 * sizeof(*lines)); // allocate 10 arrays and each array is 5 characters long
now I need a function that takes entire 'lines' :
someFunc(char ?????,...
First, I want to thank you for your answer. Now my second question is, if I need a function that takes 'lines', how do I define the parameter and how I call the function with respect to passing...
I have the following declaration:
char (*lines)[5];
I need to allocate 10 strings, and each string is 5 characters long. I used the following but did not seem to work.
lines = malloc(10 *...
Thanks Tony, your suggestion worked.
Hello, the following code fails/crashes in the second loop where it prints the content and frees the memory. But the issue could be with the first loop. Any help is appreciated in advance.
int...
The following program now works. But my question is if:
PTR ptr; and TEST **ptr; are the same what do I gain by using typedef TEST **PTR;
Please help since I am trying to understand typedef's...
It crashes and does not even print "1- debug..."
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <malloc.h>
struct _TEST
{
char msg[250];
This is not an assignment nor a project, simply reviewing struct, typedef, and pointers in combination for learning purposes, because in real world you will this kind code a lot!
Well, I am not a student rather an old programmer trying to refresh my C language. I actually have the following but it crashes when I ran it.
#include <stdio.h>
#include <string.h>
#include...
Hello, please someone show me the code for what is asked the in
the following program's comments for the variable ptr.
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include...
The following program compiles (using MS Visual Studio 2010) with no errors or warnings and runs without any error, why? Thanks in advance for explanation.
#include <stdio.h>
int f[3] = {...
This is how I did it using macro:
#define arrayToString(name, digest) { char p[3]; int i; \
for( i = 0; i < 16; i++ ){ \
sprintf(p, "%02x", digest[i]); ...
I have the following code and need to convert the array into character string and print the value later as opposed to printing it via loop:
int main( void )
{
int i;
unsigned char...
Hi, I need to use the qsort to sort the content of an unknown text file size by reading it into an array and then sort the lines. I know C language well, could someone help? I can get the file size...
Thank you all for your help.
Hi, does anyone know how to override the C run-time functions. I need to write my own malloc() function with the same function signature as Microsoft's C run-time malloc(). Any suggestion/help? When...