D33wakar 36 Posting Whiz in Training

And here's how you use strtok (you know... for future references).

#include <stdio.h>
#include <string.h>
int main(void){
    char line[20] = "Process0 12 1"; // suppose this is the first line read by fgets
    char* delim=" ";
    char* result = NULL;
    result=strtok(line,delim);
    if(result != NULL)
        printf("process:%s\n",result);//store process in an array
    result=strtok(NULL,delim);//first argument NULL except first call to strtok
    printf("quanta:%s\n",result);//store quanta in another array,you can use atoi to change
                                 //quanta to integer type

    result=strtok(NULL,delim);//first argument NULL except first call to strtok
    printf("priority:%s\n",result);//store priority in another array
return 0;
}
D33wakar 36 Posting Whiz in Training

The program runs and compiles. When I enter the two words, it gives me a bunch of random stuff when printing

That's because scanf is not used like this

scanf(x1,x2,MAXFORTHIS,stdin);

click here

D33wakar 36 Posting Whiz in Training

Can you tell me why use size_t and not int for orig_len and rep_len?

Using size_t instead of just plain int or unsigned int makes your code more portable since the size of int types vary across platforms.
Also the above standard functions expect their third argument to be of size_t type.

char *stpncpy(char *restrict s1, const char *restrict s2, size_t n);
int strncmp(const char *s1, const char *s2, size_t n);
D33wakar 36 Posting Whiz in Training
fflush(stdin);

Didn't you read my previous post ? How many times do I have to tell you that you should not use fflush() with stdin.In the c standards, it is only defined to use with the output streams.

I have another problem with the following program I have tried which tests if sides form a right angled triangle or not.

First of all, if you have another problem and the current problem is resolved then you should mark this thread URL="http://www.daniweb.com/community-center/daniweb-community-feedback/threads/226710"]"solved"[/URL] and open another thread with the new problem.

First of all, is there any unnecessary repetition?

Actually, that's your job to figure it out since you know your level of expertise and how compact you need your program to be.You can use functions to make it more short and compact.

Is there any simple way by which I can add a reply feature to the program?

That is as simple as you can get.

if(Condition)
    printf("Something");
else
    printf("something else");
D33wakar 36 Posting Whiz in Training

oh I get the point then. So, in other words it fflush can be used instead of always creating a double getchar() in the end of each prog.

No, you don't. I've already said that fflush() should not be used with input streams, it is made to use with output streams only.People usually use getchar() at the end to consume the data that might be left in the input buffer. That could be replaced with this

while (((ch = getchar()) != '\n') && (ch != EOF))//has no body ;

But still at least a character is left in the buffer.

D33wakar 36 Posting Whiz in Training

Am i correct if I understand I/O buffer
as the temporary memory stored/inputted in the variables?

see here.

.but what is its use here?

Just to make sure that everything in the buffer is written immediately after you call printf and not after sometimes when you're taking inputs from the user. Believe me it happens(or may not,it depends on the compiler you're using or the system you're running on), usually when you're trying to take inputs and give outputs subsequently.This happens because buffers are flushed out only when they're full or a newline is encountered or fflush() is called.

D33wakar 36 Posting Whiz in Training

This is a piece of code from some book.

Is that the same book Narue told you to burn ?

int fun (const union employee *e);
union employee
{
char name[15];
int age;
float salary;
};

You should declare the union first and then the function 'fun'.

union employee{
char name[15];
int age;
float salary;
};
int fun (const union employee* );//in function prototypes, you only mention the argument type
void main()//so wrong

According to the standards, main() returns an int type

int main(void)

but this code is running on turbo C giving just a error message of const to * conversion ????? please tell me whether this code is right ??????

How could that be?If the compiler issues an error message then the code should not have compiled in the first place.And yes the code is wrong!If you have used 'const' Type qualifiers then that means that you're declaring them as constants and they should not be modified during runtime.
Quote drom c-faq.com

A const value is one you promise not to modify. The compiler may therefore be able to make certain optimizations, such as placing a const-qualified variable in read-only memory. However, a const-qualified variable is not a true constant; that is, it does not qualify as a constant expression which C requires in certain situations, such as array dimensions, case labels (see section 18.3.1 below), and initializers for variables with static duration (globals and static locals).

Quote from …

D33wakar 36 Posting Whiz in Training

'fflush(stdout)' forces the data (if any)in the I/O buffer to be written to the screen .Including a '\n' character(if suitable) in the 'printf' itself also does the same thing.

printf("incorrect value\n");

Remember that fflush is only used with output streams.Calling fflush with NULL argument flushes all the opened streams.

D33wakar 36 Posting Whiz in Training

The code compiles

That totally amazes me.

but when I run the program it stops responding once it enters the while loop

So there's a strong possibility that the problem lies on your while loop statement.

while (fgetc(inFile) != EOF) != NULL) {

'fgetc' returns EOF when read error occurs or the EOF is reached.So this is enough

while(fgetc(inFile)!=EOF)

But wait a minute, the file pointer you declared has a name 'inputFile'.Also that you're using fgetc just to detect the EOF seems a bad idea to me.Instead just read the whole line at a time and extract the information you need one by one.

D33wakar 36 Posting Whiz in Training
BYTE PTR [BX+SI]

What does this do exactly though?

Si is an index register, though in the above code SI always remains zero since you had only one character (to access) in the string.While using instructions like CMP and ADD, you need to use the pointer directive 'BYTE PTR' to tell the assembler that the pointer contains a 8-bit value(or you want to access a byte). Similarly, there are other directives like 'WORD PTR','DWORD PTR' etc.So the above code is equivalent to

char *ptr="A";//BX points to the character in the buffer just like ptr here
int i=0;//SI is similar to this i
printf("%c\n",*(ptr+i));//prints the character
D33wakar 36 Posting Whiz in Training

Tell me why the compare always goes to my error message please.

See line 42 in your code.

LEA	    AX, DATASTR ;Move the character into the AX register

It is actually copying the offset address of 'DATASTR' to AX, not the character itself.Instead do like this:

LEA	    BX,DATASTR ;load the addr of character into the BX register
MOV         SI,0       ;SI=0
CMP	   BYTE PTR [BX+SI],'A'	;Compare the character to 'A'
JB	    ERRORMSG	;If the character is below 'A' then go to error message
CMP	    BYTE PTR[BX+SI],'a'	;Compare the input character to lowercase 'a'
JB	    TESTCAPITAL	;Jump below if the character is less than 'a'

Here, BX is used to load the offset address, because it's the only general purpose register allowed to do so in real mode assembly.
Similarly, your 'TESTCAPITAL' will look like this:

TESTCAPITAL:
CMP	    BYTE PTR [BX+SI],'Z';Compare the input character to uppercase 'Z'
JA	    ERRORMSG	;If the character is in the no-man-land part of the chart, display error.
JB	    CONLOW      ;If it's between capital 'A' and 'Z' then convert to lower!

and your CONLOW

CONLOW:
ADD	    BYTE PTR[BX+SI], 20H;CONVERT from upper to lowercase!
mov         AH,06h              ;DOS function to print a character
mov	    DL,[BX+SI]          ;Print the character
INT	    21H

If you want to use

MOV AH,09H
LEA DX,DATASTR
INT 21H

then, you have to setup your buffer like this:

MAX DB 2 ;maximum input length
ACTUAL DB ?
DATASTR DB 1 DUP(' ') ;size is inputlength+2
        DB '$'        ;end of string(required to use AH=09H function)

Do that and …

D33wakar 36 Posting Whiz in Training

Would I loop until the user presses the enter key with no input?

I'm assuming that your program takes in a character(a-z or A-Z) and displays a character as output(and your c++ sample is doing the same thing). Here's the pseudocode(well.., kind of.)

-take user input
-if input==10(i.e.'\n'), then exit the program.
-if 65 <= input <= 90 then change it to lower case and print it and then jump back to take another input
-if 97<= input >= 122 then change it to upper case and print it and then jump back to take another input
-else then print the warning message, and again loopback to take the input.

The ascii table might come in handy.

How would I test that condition using the proper syntax?

here's an example :

mov ah,8 ;dos function to get a character, the character is stored in 'al'
int 21h  ;most important interrupt in dos,executes a system call to perform the above function
cmp al,10d  ; check if user pressed <enter> key
je warning  ;then print the warning message
;je means 'jump if equal' and 'warning is a label'

Here's the intel x86 jmp instruction reference for you.

D33wakar 36 Posting Whiz in Training

just use

char* bus
char* dest
.../*and later*/
bus="single-decker"
dest="taiping"
D33wakar 36 Posting Whiz in Training

Now, if anyone would be willing to assist me I would greatly appreciate it!

I don't know what you need help with, since you have it all figured out.If you want us to write(or translate) your code for you, the forum rules wouldn't allow it.

You have to use software interrupts to get input from keyboard and to print output to the screen. See Ralph Brown's Interrupt List.
Do some research on how to do your assignment and write your code.Post your code here even if it's broken, we'll help you to fix it.
Cheers and happy coding!

D33wakar 36 Posting Whiz in Training
for(c_5=1; c_5<=10;c_5++)
          {
            for(c_6=c_5;c_6>=1;c_6--)
              printf(" ");
              for(c_6=10;c_6>=c_5;c_6--)
             printf("*");
             printf("\n");
            }
            printf("\n");
          getch();

initialize c_5 to 0 instead of 1.

for(c_5=0; c_5<=10;c_5++)
D33wakar 36 Posting Whiz in Training

.for some reason sorting resets all entries to blank.Why is it doing that? I compare two entries, swap if necessary. Trying to figure out where that's failing.

I compiled and ran your program, It works fine.
In my opinion, in your 'DeleteEntry' function, try matching only the user's phone number, because even if I entered a correct firstname with incorrect surname(which is not in the phonebook), then the entry for which the first name matched will be deleted.As there may be some users whose surname or firstname or both matches with each other.But that's only my opinion.

D33wakar 36 Posting Whiz in Training
int main( int argc, char **argv[] ) {//Wrong
int main( int argc, char *argv[] ) {//right
D33wakar 36 Posting Whiz in Training

It shows the same prompt multiple times

That's because the 'printf' statement is inside the loop and you don't need to pass that 'i'.You can do like this:

int main (void)//this is more readable, isn't it?
{
    int n, smallest=0, i=0;
    printf ("Enter a list of positive integars:\n");//printf outside the loop
    while (scanf("%d", &n)!=EOF){//press ctrl+Z to break out of the loop
		if(n==-1)
		    break;
		if (n<=smallest)
		    smallest=n;
		i++;
	}

	printf("The smallest among the %d integars is %d.\n ",i,smallest);

	return (0);

}
D33wakar 36 Posting Whiz in Training
void print_triangle_info(int area(), int perimeter());
void print_square_info(int area(), int perimeter());

Are 'area' and 'perimeter' functions? If not, why give parentheses after them.the correct form of prototyping will be:

void print_triangle_info(int, int);
void print_square_info(int,int);//takes two integers as arguments and return nothing(void)

and then their definitions

void print_triangle_info(int area, int perimeter) {//no parentheses after area and perimeter
//Now make use of the area and perimeter to print "triangle info"
}

and then call them from 'main'

int main(void) {
//calculate area and perimeter here or create functions to calculate them outside the 'main'

print_triangle_info(area, perimeter);
print_square_info(area, perimeter);
}

edit:
@ WaltP- Wow, that was quick!

minimi commented: Thank you for the heads up! +2
D33wakar 36 Posting Whiz in Training
int ok = 0;
for (x=0;x<=2;x++)
 {
 y=0;
 y++;
  if(c[x][y] ==d[x][y])
  ok = 1;
}

It only compares
c[0][1] with d[0][1]
c[1][1] with d[1][1]
c[2][1] with d[2,1] and so on.
If You want to compare each of the elements then, put it in a nested loop

for(x=0;x<2;x++)
    for(y=0;y<2;y++)
        if(c[x][y]==d[x][y])
        //rest of the code...
D33wakar 36 Posting Whiz in Training
int a,b;
a = b;//bad practice
char c[2][2];
char d[3][3];
c = d;

Well?Why don't you try that in your compiler? the answer is no. you cannot do that with arrays.

// or can you compare two arrays to get a true or false statement?
if ( c == d)

Though the compiler doesn't report any error in this case, you'll not get the intended result from it.Because here, the addresses of arrays c and d are being compared for equality which is never true.

// or if I want to know if two signs in an array are equal:
if ( c[1][2] == d[1][2])

This is the correct form.

Is it possible to use the equal sign = on arrays like you can use it on variables. If yes how do I write it correctly?

Suppose you have an array

int array[5]

then you can assign values to them like this

array[0]=1;//1st address assigned to 1
int i;//will be used as offset address
for(i=1;i<5;i++)
    array[i]=i+1;//2nd address contains 2, 3rd address contains 3 etc.
D33wakar 36 Posting Whiz in Training

In addition,
You can remove this line

#include <conio.h> //non- standard library,also not portable

'main' should always return int, like this:

int main(void)

and return statement at the end.

return 0;

add

fflush(stdout);

after the printf statements,by doing that you'll force the output to be displayed on the screen even if the output buffer is not full.
And finally don't use 'scanf' while taking string inputs,use 'fgets' instead:

fgets(name[i],sizeof(name[i]),stdin);
D33wakar 36 Posting Whiz in Training

Ola!

I'm still kind of new with the whole assembly language and just need some help with this program i'm writing.

What I want it to do is to ask a question -like for a number and then store that inserted number in a variable. And then test whether its bigger than 14 which I declared as a variable already as shown below-and then there is a loop to ask again what is the number. So I want the loop to run as many time the number the user entered.

output db 10,13, "Enter your number: $"
asq dw 10,13, "$" ; ascii values for a new line
stilltoimplement db 10,13, "Do calculations later on $"

.code 
    
jmp start 

    number db ?
    max db 14 ;max number
    
start:
    mov ax,@data 
    mov ds,ax
    
    mov ah,09 ;prints new line
    mov dx, offset output
    int 21h
    
    mov ah, 01 ;checks for key
    int 21h
    mov number, al
    
    cmp max,number
    jg start
    jl part2

part2:

    mov ah,09
    mov dx,offset stilltoimplement
    int 21h
    
ending:
    mov ah,4ch
    mov al,00
    int 21h ;End the program
    
END

It gives me an error in where I try to compare the two variables and says Illegal memory reference. Prob just something small

Any help will be appreciated!

Thanks

In line 24..
You can not use cmp with both operands being a memory variable. Instead use an immediate value

cmp number,14d  ;the immediate value must be the second operand

or you can also do

cmp al,max
D33wakar 36 Posting Whiz in Training

...that's your homework

I'm sorry that I sounded like your professor up there, but my only intention was to help you find the bug, and it was simple so I thought that you were able to find that on your own.

I'm thinking that your solution was the following for line 9.

printf("%d", matrices[Index][i])

No, it was not.
It was this:

printf("%d",matrices[i]);

Because, the pointer "matrices" you're passing to the function "Display" is equivalent to "matrices[index]" for which you dynamically allocated memory in your 'main'

matrices [Index] = (int *) malloc( size * sizeof(int));

And you only got the first member because 'Index' in your 'Display' function always remains zero.
So you can also do like this:

for (Index = 0; Index <= size; Index++)
{
    printf("%d", matrices[Index]);
}

And also I can't believe that someone who has done several projects is still having trouble understanding the concepts of pointers and then applying them?

D33wakar 36 Posting Whiz in Training

I don't understand - why compiler allows such code =

You can do like this then.

#if defined(_WIN32)||defined(_WIN64)

//Windows specific includes and code goes here..

#elif defined(linux)

//linux specific includes and code goes here..

#endif
D33wakar 36 Posting Whiz in Training

I now am having a problem entering values into the dynamic memory.

It's not a good idea to ask for favors for every single problem you face. You should learn how to debug your own code at least.

Line 17-20 is a for loop to increment the variable 'i' so a series of different values will be stored in the dynamic memory. However, it only reads in the first value and ignores the rest.

The problem is in your 'Display' function (in line 9 of your second code-see carefully) and that's your homework.

D33wakar 36 Posting Whiz in Training

That means he is using a different compiler than you are. Just ignore it.Pelles C has no such option.

Yes, it does.
Actually if "Enable Microsoft Extensions" option is unchecked, then compiler will issue the message:

If you are compiling a Windows program, make sure you use the /Ze option!

So '-Ze' is a command line option for the compiler which means 'Enable Microsoft Extensions'. Anyways, I'm glad that the issue has been resolved.

but the winmain() is the entry point for windows program.....
why compiler doesn't compiler such code =

This example code may help you, it compiles as a 'win32' EXE.

#include <windows.h>

void NewLine(void);
void ScrollScreenBuffer(HANDLE, INT);

HANDLE hStdout, hStdin;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo;

int WINAPI WinMain(HINSTANCE hInst,  HINSTANCE qwe,LPSTR qwer, int ss){
    LPSTR msg="This is a win32 console";
    DWORD cWritten,cRead;
    char chBuffer[256];
    
    //Create console
    if(AllocConsole()==0){
        MessageBox(NULL, TEXT("AllocConsole"), TEXT("Console Error"),
                   MB_OK);
        return 1;
    }
    
    // Get handles to STDIN and STDOUT.
    hStdin = GetStdHandle(STD_INPUT_HANDLE);
    hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
    if (hStdin == INVALID_HANDLE_VALUE ||hStdout == INVALID_HANDLE_VALUE){
        MessageBox(NULL, TEXT("GetStdHandle"), TEXT("Console Error"),
                   MB_OK);
        return 1;
    }

    // Write to STDOUT and read from STDIN by using the default
    while (1){
        if (! WriteFile(
            hStdout,               // output handle
            msg,                   // prompt string
            lstrlenA(msg),         // string length
            &cWritten,             // bytes written
            NULL) )                // not overlapped
        {
            MessageBox(NULL, TEXT("WriteFile"), TEXT("Console Error"),
                MB_OK);
            return 1;
        }

        if (! ReadFile(
            hStdin,    // input handle
            chBuffer,  // buffer to read into
            255,       // size of buffer
            &cRead,    // actual bytes read
            NULL) )    // …
vedro-compota commented: ++++++ +3
D33wakar 36 Posting Whiz in Training

If you want to run the above program, you should compile it as a console program. But when I compiled and ran your program,the winmain part didn't show up. I had to comment out the 'main' part to do so.

#include <stdio.h>
#if defined(_WIN32) || defined (_WIN64)
   #include <windows.h>
   #define WINDOWSS 1;
#endif
int mainmenu(void);
/*int main()
 {
	 char* mtext = " Please specify the number of the task. \n * You can choose on number from set = {1} \n * Specify \"0\" to exit\n" ;

   mainmenu();
  printf("\n%s",mtext );
  getchar();


 }*/
#if defined WINDOWSS

int WINAPI WinMain(HINSTANCE hInst,  HINSTANCE qwe,LPSTR qwer, int ss)
{

	 mainmenu();
char* mtext = " running WinMain version. \n" ;
  printf("\n%s",mtext );

 return TRUE;
 }
#endif

int mainmenu(void)
  {
     char ch;
	 char* mtext = " Please specify the number of the task. \n * You can choose on number from set = {1} \n * Specify \"0\" to exit\n" ;
	 char* errmes = " Error(!) = Main menu does not support this command.\n Make sure that your task number is from menu set of commands and try again. " ;
	 printf("\n%s",mtext );
	 ch = getchar();
	 switch(ch)
     {
		case '0': exit(0);
		case '1': exit(0); break;
		default: printf("\n%s\n", errmes);
	 }
 return 1;
  }
output

 Please specify the number of the task.
 * You can choose on number from set = {1}
 * Specify "0" to exit


 Error(!) = Main menu does not support this command.
 Make sure that your task number is from menu set …
D33wakar 36 Posting Whiz in Training

Thanks alot ! it works :DDDDD Thank you! :DDDDDD

heres the final code in TASM :D

.model small
.stack 100h
.data
a db 0
t1 db,10,13, "Enter a number: $"
t2 db,10,13, "The sum is: $"

.code
main proc
	mov ax,@data
	mov ds,ax

	mov ah, 9
	lea dx, t1
	int 21h

	mov ah, 1
	int 21h  ; to get a single number input from the user
	sub al, 30h ; to make the input number to decimal
	mov a, al ; move the content of al to a variable

	mov ah, 9
	lea dx, t1
	int 21h

	mov ah, 1
	int 21h 
	sub al, 30h

	

	add al, a ; add the contents of al and a
	
	push ax

	mov ah, 9
	lea dx, t2
	int 21h
	
	pop ax
	

	xor ah,ah ;ah=0
	call put_num

	
 
	mov ah,4ch
	int 21h

main endp

 
put_num  proc		;function put_num: prints value stored in  the ax register
			;(a 16 bit integer) to stdout	
	push ax		;save registers
	push bx	
	push cx
	push dx
	xor cx,cx	;cx=0
	mov bx,10d	;bx=10(decimal)
 
PNloop1:xor dx,dx	;dx=0
	div bx		;dx=ax/bx
	push dx		;push the result in stack 
	inc cx		;cx++(cx acts like a counter to notify how many digits in the number) 
	cmp ax,0	;but if the ax was zero,                           
	jnz PNloop1	;then jump to PNloop1                              
	mov ah,2	;otherwise...(Dos function to print a character)   
PNloop2:pop dx		;get the value just pushed in to the stack in dx,  
	add dl,48	;convert it in to ascii 
	int 21h		;and print it		                 				
	dec cx		;decrease counter …
D33wakar 36 Posting Whiz in Training

Remove this line

int mainmenu();

from both 'main' and 'winmain'.
and add a prototype of the function mainmenu at the beginning .

...
int mainmenu(void);

int main()
...
vedro-compota commented: ++ +3
D33wakar 36 Posting Whiz in Training

It's a procedure, just call it from your main program like this:

.model small
.stack 100h
.data
a db 0
.code
start:
	mov ax,@data
	mov ds,ax
	mov ah, 1
	int 21h  ; to get a single number input from the user
	sub al, 30h ; to make the input number to decimal
	mov a, al ; move the content of al to a variable
	mov ah, 1
	int 21h 
	sub al, 30h
	add al, a ; add the contents of al and a
	xor ah,ah ;ah=0
	call put_num

	mov ah,4ch
	int 21h

put_num:		;function put_num: prints value stored in  the ax register
			;(a 16 bit integer) to stdout	
	push ax		;save registers
	push bx	
	push cx
	push dx
	xor cx,cx	;cx=0
	mov bx,10d	;bx=10(decimal)

PNloop1:xor dx,dx	;dx=0
	div bx		;dx=ax/bx
	push dx		;push the result in stack 
	inc cx		;cx++(cx acts like a counter to notify how many digits in the number) 
	cmp ax,0	;but if the ax was zero,                           
	jnz PNloop1	;then jump to PNloop1                              
	mov ah,2	;otherwise...(Dos function to print a character)   
PNloop2:pop dx		;get the value just pushed in to the stack in dx,  
	add dl,48	;convert it in to ascii 
	int 21h		;and print it		                 				
	dec cx		;decrease counter
	jnz PNloop2	;if cx not zero (still digits left) then loop again.
			;otherwise ..
	pop dx		;restore registers and return
	pop cx
	pop bx
	pop ax
	ret
end start

Note that the above is a masm code.

D33wakar 36 Posting Whiz in Training

I had written a procedure for displaying integers on the screen a while back, this might help you with your problem.The code is full of comments so I hope you'll not have a hard time figuring out what it does.

put_num:		;function put_num: prints value stored in  the ax register
			;(a 16 bit integer) to stdout	
	push ax		;save registers
	push bx	
	push cx
	push dx
	xor cx,cx	;cx=0
	mov bx,10d	;bx=10(decimal)

PNloop1:xor dx,dx	;dx=0
	div bx		;dx=ax/bx
	push dx		;push the result in stack 
	inc cx		;cx++(cx acts like a counter to notify how many digits in the number) 
	cmp ax,0	;but if the ax was zero,                           
	jnz PNloop1	;then jump to PNloop1                              
	mov ah,2	;otherwise...(Dos function to print a character)   
PNloop2:pop dx		;get the value just pushed in to the stack in dx,  
	add dl,48	;convert it in to ascii 
	int 21h		;and print it		                 				
	dec cx		;decrease counter
	jnz PNloop2	;if cx not zero (still digits left) then loop again.
			;otherwise ..
	pop dx		;restore registers and return
	pop cx
	pop bx
	pop ax
	ret
D33wakar 36 Posting Whiz in Training

Im using tasm xD
In command prompt.
what i mean is everytime i want to display it, it display the @,?,A,B,C etc. when the sum exceeds to 10,11,12,13,14 etc

Instead of explaining what you meant, had you posted your code here, you may have already got the solution.

D33wakar 36 Posting Whiz in Training

but what about point between words - it's feature of objective programming , but original c is functional language , isn't it?
if "isn't" how can it be implemented without objective style?

Well, WNDCLASS is a structure defined in 'windows.h' and the contents of a structure are accessed with a dot operator, remember!
See here .

vedro-compota commented: +++++ +3
D33wakar 36 Posting Whiz in Training

i have a question sir/ma'am. My professor wants that the output should be in a table and in a sequence. how can i do that? or that it is not possible?

You mean like this :

for (a=0;a<5;a++){
    for (j=0;j<5;j++)
        printf("%d\t",x[a][j]);
    printf("\n");
}
D33wakar 36 Posting Whiz in Training

%u is a format specifier for an unsigned integer used in printf and scanf.

D33wakar 36 Posting Whiz in Training

You might want to add a getchar() after that scanf ,

...
printf("Enter name, price and pages\n");
fgets(b[i].name, 25, stdin);
scanf("%f %d", &b[i].price, &b[i].pages);
getchar();
}
...

After scanf has read your input ,a '\n'(which was typed just after the number) is still left in the input buffer, so we use that getchar to empty the buffer.
scanf() is a bit complex function to handle, especially when taking input interactively from the user. It'll fail to do the job at hand if it doesn't get what it is expecting.Here in your program, user must enter a string followed by a floating point number followed by an integer.If a user fumbled and mistakenly (or intentionally) entered a floating point number instead of an integer, the program will misbehave.
So I'd suggest you to use fgets even also to read the numbers the from user and later convert them using atoi and atof to their respective formats.

D33wakar 36 Posting Whiz in Training

IN line 17, the '%c' should be replaced by '%s' since name is a string(an array of characters) not a single char.
Same thing in line 21 while using printf.
Despite the above changes alot could go wrong with your program. Try using fgets() instead of scanf while taking strings as input.
I just entered "Ban ki Moon" for the 'name' part and your program fell apart.

D33wakar 36 Posting Whiz in Training

my bad help me convert cout to printf and cin to scanf.. help me pls asap

here you go:

int printf(const char *format, ...)

But you have to include header file "stdio.h"("cstdio.h" if you're compiling as c++) in your code to use printf or scanf.
simple example of printf:

printf("Hello, world!\n")

Here's more about printf and scanf.

Use fgets instead , since scanf is not considered safe.

D33wakar 36 Posting Whiz in Training

It's a good thing that you posted your code, but you should compile it first to see if there are any typing errors or syntax mistakes.Here I have posted your code with some corrections.There are comments in each corrected line so you can easily match it with your original code to see where the mistakes were.
You'd better not use the non standard header "conio.h",since it is not portable.getchar() will do same thing as getch(),except you may have to press an extra <enter> key to get the job done.

#include<stdio.h>
#include<conio.h>//don't use this header 

int intpart(float x)
{
 return x;
}

float decpart(float x)
{
 return x - intpart(x);
}

int roundoff(float x)
{
 if(decpart(x) >= 0.5)
 {
 return intpart(x) + 1;/*no space between int and part*/
 }
 else
 {
 return intpart(x);
 }
}

int main()
{
 int arx[100],n,a,b,hs,ls,range,cs;
 int arlow[11], arhigh[11];
 float arcm[11]; //may be you should declare arcm as an array of 11 floats

clrscr(); /*had used colon instead of semicolon, why do you need to clear the console anyway*/
printf("Enter number of scores: "); scanf("%i", &n);

if(n<1 || n > 100)
{
 printf("Invalid no. of scores");
 getch();//use getchar() instead
 return 1;
 }

for(a=0; a<n; a++)
{
printf("%i", a+1);
scanf("%i", &arx[a]);
}

hs = arx[0];
for(a=1; a<n; a++)
{
 if(arx[a] > hs)
 {
 hs = arx[a];
 }
}

ls = arx[0];
for(a=1; a<n; a++)
{
 if(arx[a] < ls)
{
 ls = arx[a];
}
}
range = hs - ls;
cs = roundoff(range / 10.0);//missed semicolon

a=0; …
D33wakar 36 Posting Whiz in Training

honestly i was new to C and i just need a codes for finding the mean for grouped data. i hope this site can least help me. you have my thanks.

Nobody's gonna provide you a full working code for you, you should write it yourself.This site does help those who "help themselves".
What do you "mean" by "grouped data"?
Have you started yet or you're hoping that someone here will give you the code(not even knowing what you actually want),if the case is latter you're gonna be very disappointed.
In the former case, you might post next time with the exact questions(of where you're stuck in your program and with what exactly you need help with).

D33wakar 36 Posting Whiz in Training

You may need to reread his posts and try to understand the format of the file.

And have you understood the format of the file yourself? if so, do you mind explaining it to me.(since OP doesn't seem to interested in explaining that, he has got his own problems).

Your code is woefully inadequate.

I was just trying to explain the OP how to handle multi-dimensional arrays there.That was supposed to be a base code for his program.

I believe this bit of code will take care of the first line of the array, but how do i get the next lines. I think I need to have this in while loop because when i get to the words at the end, each word will temporarily go into the buffer so i can send it to a function that finds the word which i have yet to write.

DO you even try to compile your code before posting here?
Have you read everything there is to know about arrays?
From the way you have written your code, I don't think so.
I'm not trying to be rude here but if you haven't, read it first.

D33wakar 36 Posting Whiz in Training

since fgets will not do what you're trying to do:

while(fgets(inarray,sizeof(inarray),stdin) !=NULL)

Because fgets reads the chars in to "an array", and you're giving the address of "three" arrays ((3X3) means array of 3 arrays of chars) to it.
You can easily read chars in to the array with getchar() , no need to use fgets() (unless you've been explicitly told to ).
This example may help you.

#include <stdio.h>
/*based on your example illustration
A B C                           
E F G                             
H I J
*/
int main(void){
    char inarray[3][3];
    int i=0,j=0,c;

    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            inarray[i][j]=(char) getchar();

    for(i=0;i<3;i++)
        for(j=0;j<3;j++)
            printf("%c",inarray[i][j]);

return 0;

}
D33wakar 36 Posting Whiz in Training

I can tell because main() uses implicit int, which was removed in C99.

Even though compilers supporting c99 features(E.g. LCCwin32->that's what I'm using right now) give warnings if int is omitted before main().
"no type specified.Defaulting to int. "

Also while compiler language extensions are on and warning level is set to max,
using

int main()

gives warnings like
"old-style function definition for 'main'."
"missing prototype for 'main'"

That was not the case with

int main(int argc,char* argv[])

though( cause I was running out of 'main' definitions.)

D33wakar 36 Posting Whiz in Training

It's because of this line

int a[n];

You cannot declare arrays like that.
Here either 'n' should be initialized prior to declaring array

printf("Enter size:");
scanf("%d",&n);
int a[n];

or n should be replaced by some constant value.
like this:

#define BUFFER 100
...
int a[BUFFER];
challarao commented: Thank you +2
D33wakar 36 Posting Whiz in Training

if you did't understand the code .once again

import threading
import time
def msg():
    print "time's up"
    time.sleep(2)#just enough to show the above msg    
    exit()
t=threading.Timer(5.0,msg)
t.start()

Since I'm not a guru myself(As u can see I'm a Newbie poster)so I'm looking for it myself.
I'll inform u if I got anything useful.

D33wakar 36 Posting Whiz in Training

You can use ' threading ' module.

import threading
import time
def msg():
    print "time's up"
    time.sleep(2)#just enough to show the above msg    
    exit()
t=threading.Timer(5.0,msg)
t.start()

But you have to figure out how to use it with Raw_input. Don't hesitate to ask.Go on.

D33wakar 36 Posting Whiz in Training

The error message says that the 'return' statement is outside the function.
What's with the line 17:
return param2+1

D33wakar 36 Posting Whiz in Training

Yeah but the previous code gives more promising result that the latter.
Similar to that:

from Tkinter import*
import time
class myapp(Frame):
    def __init__(self,master=None):
        Frame.__init__(self,master)
        self.grid()
        self.weeds()
        
    def weeds(self):
        self.button=Button(self,text='Button',command=self.onclick).grid()        
        self.var=StringVar()
       
        self.msg=Label(self,textvar=self.var)
        self.msg.grid()
    def onclick(self):        
        self.var.set("Running command..")
        self.msg.update_idletasks()#remember to update "idle tasks"-**
        time.sleep(1.5)            #otherwise your message waits until
        self.nest1()               #mainloop 
    def nest1(self):
        self.var.set("Still Running.")
        self.msg.update_idletasks()#**
        time.sleep(2)
        self.nest2()
    def nest2(self):
        self.var.set("Not yet.")
        self.msg.update_idletasks()#**
        time.sleep(1.5)
        self.nest3()
    def nest3(self):
        self.var.set("Finished")
        self.msg.update_idletasks()#**
        
        
        
root=Tk()
APP=myapp(master=root)
APP.mainloop()
D33wakar 36 Posting Whiz in Training

It would have been better to understand your problem if you had posted your code here.
Sure I'll help.