19,876 Topics

Member Avatar for
Member Avatar for saurabh.mehta.33234

main() { union u { struct s{int a;int b}n; struct ss{int c;long d}ni; }uu; uu.ni.c=1; uu.ni.d=0; printf("%d %d",(uu.n.a),(uu.n.b)); } output: 1 32767 Now my question is that even though I put d=0 then why does it shows 32767 as output for b?As per my knowledge union members share the same …

Member Avatar for saurabh.mehta.33234
-1
125
Member Avatar for finston

I have compiled and linked my code written in C and C++ and calling certain Windows APIs to a Win32 .dll using MinGW in Code::Blocks runnings on Windows XP. My code has also been compiled to and linked to create a Win32 .exe, which works successfully whilst communicating serially from …

Member Avatar for Ketsuekiame
0
239
Member Avatar for mical700

How to convert C++ code to C. Write a program in C that asks a user for the name of a file. The program should display the first 10 lines of the file on the screen (the "head" of the file). If the file has fewer than 10 lines, the …

Member Avatar for deceptikon
0
1K
Member Avatar for otengkwaku

Hi guys i know that in linux you create a c file and use make or gcc or clang to compile it and then run it. My question is how do you run a c file or c++ file in vs2012 with out creating a solution. Also how do you …

Member Avatar for otengkwaku
0
336
Member Avatar for BWASS

I want to read a datafile which consits of 5 coloums and 4 rows, which consists of numbers seperated by commas. The first line of the data file looks like this: 103343, 24, 55, 24,12. I have started my program by allowing to input the file in my program, however …

Member Avatar for deceptikon
0
106
Member Avatar for SQLpower

Hello, I have a datagridview, where I can edit only 1 field, howerver, I cannot type "4,556" because I restricted it to only number, and if I type 0345, or "0,345" it will just save it as 345. `<asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("AMOUNT") %>' BackColor = "#FF960C" MaxLength="4" onChange="intOnly(this);" onKeyUp="intOnly(this);" …

Member Avatar for SQLpower
0
297
Member Avatar for Learningvinit

When we pass arg which is of type va_list as a parameter to a different function which calls vsprintf and vfprint giving one of the parameter as args, It gives core dump. But when we make a copy (i.e va_copy) and pass copy to one of vsprintf or vfprintf and …

Member Avatar for L7Sqr
0
541
Member Avatar for saurabh.mehta.33234

I came across the foll code: #include<stdio.h> main() { int i=4,j=7; j=j||(printf("you can")&&(i=5)); printf("%d %d",i,j); } output: 4 1 Athough I am specifying the braces for the && operator so that it gets executed first..Then also the value of i remains 4 only..Why doesnot it gets changed to 5??Also the …

Member Avatar for Banfa
-1
232
Member Avatar for SoulofchaOs

After I clicked the 'Run' button in Netbeans, it will compile and run and then it will stop at this point : [Click Here](http://i.imgur.com/4O8vY2d.png) I will have to press any key on the keyboard then it will display the text, but it doesn't allow the user to enter any form …

Member Avatar for tinstaafl
0
226
Member Avatar for noble3ad

Hello all, I'm suppose to write a program that asks the user to input five numbers. Out of those five numbers, the program is suppose to select the maximum value. I attempted to do it with "else-if" statements as can be seen in the following code. I was hoping there …

Member Avatar for arunkumar4003
0
464
Member Avatar for Akshay nand

Lab Assignment 1 - A Simple UNIX Shell Objectives: The objective of this assignment is to understand the workings of a command-line interface (CLI) and to obtain a working knowledge of process forking and signalling. Assignment: In this assignment we will build a command shell in stages. Our command shell …

Member Avatar for deltascrow
0
335
Member Avatar for smith32

Hi, Here is the File content. I want to use strtok to separate each. but the problem is if i use `strtok(string, "\",");`, the zip code (19428) of the detail is miss place and take State (PA) for the first record Because of "," in State. Although the second one …

Member Avatar for smith32
0
1K
Member Avatar for tyler.dahle

if(kbhit()){ getch(); if(getch() == ' '){ while(y9 < 770){ readimagefile("PIX\\thunderball\\thunderball.gif", x9+10, y9+40, x9+40, y9+70);Sleep(80); putimage(0, 0, background, COPY_PUT); readimagefile("PIX\\thunderball\\thunderball2.gif", x9+10, y9+40, x9+40, y9+70);Sleep(80); putimage(0, 0, background, COPY_PUT); readimagefile("PIX\\thunderball\\thunderball3.gif", x9+10, y9+40, x9+40, y9+70);Sleep(80); putimage(0, 0, background, COPY_PUT); y9++;}} if(y9 == 730){ readimagefile("PIX\\thunderball\\thunderball_contact.gif", x9, y9, x9+30, y9+30);Sleep(80); putimage(0, 0, background, COPY_PUT); readimagefile("PIX\\thunderball\\thunderball_contact2.gif", …

Member Avatar for tyler.dahle
0
199
Member Avatar for kux

ok, I've checked the forum and I don't think this topic was touched. What I would need is an open-source or at least free static analysis tool for C++ code. Does anybody have any suggestions? I mean, searching the web C++ lacks A LOT at this chapter, compared to Java, …

Member Avatar for IssamLahlali
0
255
Member Avatar for kent.johnstone_1

Hello, I thought when creating a struct, I could call it anything I want. However, in the line: static struct usb_device_id usbtmc_devices[] = {... my compiler gives me "unable to resolve identifier 'usb_device_id'". Are struct names supposed to be defined somewhere else?

Member Avatar for kent.johnstone_1
0
125
Member Avatar for asmona

heyyy im trying to write a code to read from a file book name#Auther#subject#year the title takes 50 char anth then wanna sorted using bucket sort and continue by ( write to the file ) i just dont know how ! could u help me ?!

Member Avatar for deltascrow
0
86
Member Avatar for jchimz

Hi I need detail on using pictures in c code.My system has to upload,store and display picuters.Please help.

Member Avatar for Schol-R-LEA
0
109
Member Avatar for liphoso

Hope this is the correct place to put this question. i am new to linux and am runnning ubuntu 12.04. I just installed Netbeans 7.0.1 and xampp 1.8.1, both running on ubuntu. i would like to make a c++ program that uses the MySql database that comes with xampp. I …

Member Avatar for pritaeas
0
95
Member Avatar for hayate98

// code says misplaced else can some tell me why and if possible make the correction? #include<stdio.h> #include<conio.h> char oper; int num[2]; int ans; main() { clrscr(); printf("Num:"); scanf("%d",&num[0]); printf("+"); scanf("%c",&oper); { if(oper=='+') { printf("+"); } { printf("Num:"); scanf("%d",&num[1]); } ans = num[0] + num[1] ; printf("%d",ans); } { else …

Member Avatar for hayate98
0
174
Member Avatar for thexile

Hi How do I go about reading from a file (Input_image.txt) that contains a 2-D (50 by 100 = 5000 elements) array? E.g. > 000 004 567 034 ... > 001 046 923 987 ... > 004 345 003 745 ... > 034 870 003 805 ... > 054 345 …

Member Avatar for Ancient Dragon
0
252
Member Avatar for dendenny01

I want to designe a code at display a perticular data Example a time table of the week For instance if someone view a page on monday so it show display result of the table or data which is set to display on monday or if some one view same …

Member Avatar for dendenny01
0
294
Member Avatar for Decode098

This code wont doest display the answer why???/ #include <stdio.h> #include <conio.h> void main() { int opcode; int num[2]; int result; clrscr(); printf("Program for Addition, Subtraction, Multiplication and Division\n"); printf("Enter First Number:"); scanf("%d", &num[1]); printf("Enter Your Choice: 1 - Add, 2 - Sub, 3 - Mul, 4 - Div: "); …

Member Avatar for Decode098
0
135
Member Avatar for jethro28

#include<stdio.h> #include<conio.h> #include<ctype.h> char c,ch; //choosing long int dec,quotient; // long int *pdec; // int bin[100],i=1,j; //Binary int *pbin,*pi,*pj; // long int octal,*poctal; //Octal long int hexa,*phexa; //Hexadecimal main() { clrscr(); gotoxy(5,7); printf("A. Binary"); gotoxy(5,8); printf("B. Octal"); gotoxy(5,9); printf("C. Hexadecimal"); gotoxy(5,5); printf("Convert decimal to: "); scanf("%c",&c); c=toupper(c); { if(c=='A') { …

Member Avatar for jethro28
0
184
Member Avatar for nerdygirl118

The assignment is to implement the Banker's Algorithm using pthreads and mutex locks. We implemented the Banker's Algorithm and it works fine. When we began implementing the pthreads and mutex locks we ran into problems. We know that each process is a thread, and that the mutex lock is acquired …

Member Avatar for deceptikon
0
155
Member Avatar for Manasarala

hi, Below is the code that displays 2 similar images and pixel values BGR of both images. I wanted to know , how to calculate the distance(euclidean) between selected pixels in 2 images[like (100,100),(100,101) coordinate and so on.how to go about it?how to use the values of BGR and B1G1R1 …

0
146
Member Avatar for Decode098

Is there a possible way to stop an incrementing array ex. A[9]1~10 normaly it goes like 1 2 3 4 5 6 7 8 9 10 but is there a way that if a press a key it will stop at that point?? ex. 1 2 3 4 5[key pressed] …

Member Avatar for dendenny01
0
201
Member Avatar for shhhhhh14

Help me with writing a program that calculates the average value of the elements of a 1- dimensional array of size N.

Member Avatar for rubberman
0
103
Member Avatar for Learningvinit

I was using certain lex and yacc file on 32 bit little endian Linux machine with gcc compiler. Now its upgraded to 64 bit it little endian Linux machine with icc compiler. I am facing lots of run time error which was not there earlier. Can anyone help me out …

Member Avatar for rubberman
0
178
Member Avatar for Decode098

This Programs is a Simple Calculator that usses Arrays and pointers. Currently a freshman student and im completely lost on the errors i keep on getting #include<stdio.h> #include <conio.h> main() { clrscr(); int num1[5],num2[5],sum[5],*n1,*n2,x; char oper[4],*o; *n1 =num1[5]; *n2 =num2[5] *o = oper[4]; oper[0] ='*'; oper[1] ='+'; oper[2] ='-'; oper[3] …

Member Avatar for cproger
0
321
Member Avatar for terabyte

Many string functions seem to work without the null byte... is it necessary to add it all the time? and my second question, does scanf %s automatically ads the null byte?

Member Avatar for deceptikon
0
143
Member Avatar for Kristjon

1 1 1 1 1 1 1 1 1 1 1 1 0 0 0 1 0 T 0 1 S 0 0 1 1 1 0 1 1 1 1 1 0 0 0 0 0 0 0 1 1 1 1 1 1 1 1 1 1 1 …

Member Avatar for Moschops
0
123
Member Avatar for terabyte

seems like I never need malloc to allocate memory dinamically when it comes to strings example: int main(void) { char *str; puts("keyword:"); scanf("%30[^\n]\n",str); printf("%s",str); } I never defined str size, yet it works sorry if this is a stupid question it's 2 am and I'm studying for some c quiz …

Member Avatar for sepp2k
0
117
Member Avatar for mical700

I have problem reading file form command line. I am trying to do " abcd: ./rev < numbers", but it gives me an error: ./rev < numbers Usage : ./rev FILENAME Here is the code: #include <stdio.h> #include <stdlib.h> void reverse(FILE * file) { int fscanf_return_value; char x; /* read …

Member Avatar for mical700
0
369
Member Avatar for cupin06

The program i want to code is user will enter 2 ebook title,edition,year and pages.After that must write to binary file and read the binary file again to found the book with the highest pages.The first problem is why i cannot use this statement. printf("Enter ebook title: \n"); scanf("%s",mybook.title[i]); I …

Member Avatar for Ancient Dragon
0
206
Member Avatar for nina.le.92

The goal of my assignment is to create a program that takes a string of words and encodes or decodes the string using a simple substitution cypher. I've gotten a decent amount done but I am stuck at the part where I actually have to encrypt and decrypt using the …

Member Avatar for Banfa
0
269
Member Avatar for Perry31

Hi, I have jpeg image of JFIF type, i want to read jpeg image, decode it and finally i want to display this image in a screen. Could anyone explain me the parsing of jpeg binary data for decoding and encoding? Thanks in advance

Member Avatar for Moschops
0
165
Member Avatar for ConfusedLearner

Define an integer vector and get several input from keyboard, then display the numbers in the vector. The while loop is required to write the display loop. I am having trouble turning my program into a while loop and getting mistakes. Please help. #include <iostream> #include <vector> using namespace std; …

Member Avatar for Banfa
0
157
Member Avatar for murnesty

I read a sample code from a development kits. The global array is declared without indicating the array size. I wonder is it safe? Here is the code: #include <stdio.h> // For Used Function printf // UART Buffer char uart0_buf[]; // "sprint" UART[0] Buffer char uart2_buf[]; // "sprint" UART[2] Buffer …

Member Avatar for deceptikon
0
144
Member Avatar for dellat

I have more than one version of berkeleydb installed in my linux box and when I use -ldb to link berkeleydb to my c code I couldn't know which version is linked to. Please tell me which version is used by linker. I can't configure eclipse cdt with berkeley db …

0
72
Member Avatar for terrier_unknown

hy guys can you please tell me what s wrong with the folowing code float a,b,c; printf("input three numbers:\n"); scanf ("%f%f%f",&a,&b,&c); float z=sqrt((1/2)*(pow(a,2.0)+pow(b,2.0)+pow(c,2.0))-(3/4)*pow(a,2.0)); printf("res is %f",z); getch(); return 0;

Member Avatar for terrier_unknown
0
113
Member Avatar for alex910TN

Hey guys, I am trying to implement the following but the compiler is not liking it. What can I do to fix this? Thanks for any help. typedef struct { int ordinalSum; int LexemeCode; Line Info; Node *next; <-- ??? }Node; error # 1 syntax error before "Node"

Member Avatar for cproger
0
253
Member Avatar for anumash

#include<stdio.h> int main(){ char inputs[33]; int i; for(i;i<33;i++) inputs[i]=' '; int ch; for(i=0;(ch=getchar())!=EOF&&i<32&&ch!='\n';i++) {printf("%c",ch); inputs[i]=ch; } inputs[i]='\0'; printf("%s",inputs); return 0; } I am writing a program where the user enters a character and the program stops asking the user for a character when the user enters the Enter key. Enter …

Member Avatar for anumash
0
131
Member Avatar for dij_0983

I'm trying to develop my own simple uptime command (used to show how long the system has been running) like program where I'm gonna use it for our university's OS, (consider the OS already has all the necessary C libraries needed to make system utilities) Could someone give me a …

Member Avatar for dij_0983
0
248
Member Avatar for deceptikon

I was going to post this in a thread, but it turned into something a bit more serious and may be useful as a code snippet. The code shows three files: * menu.h: The header file for the menu library. * menu.c: Implementation of the menu library functions. * main.c: …

Member Avatar for deceptikon
3
592
Member Avatar for PolarClaw

Hello everyone, im new here and dont know yet most of the policies.. but i have been reading lots of your C++ codes, mostly, codes made by Narue.... i wonder if you someone could help me make a code for pascal's triangle wherein the ouput would look like a triangle …

Member Avatar for H A hashim
1
1K
Member Avatar for HadoukenGr

Hi, i am trying to make a server client application using sockets in C. Server and client compile just fine but they dont seem to connect with each other and i don't understand why (i just started learning about sockets). My OS is SunOs 5.10. This is my server code …

Member Avatar for Mouche
0
260
Member Avatar for ConfusedLearner

I am writing a program for class but stuck. I need my program to pick adult, child, student or senior, if I enter any of them. #include<iostream> #include<iomanip> #include<string.h> #include<fstream> using namespace std; int main() { int choice; int months; int Adult, Child, Student, Senior; cout<<"Enter the number of months …

Member Avatar for deceptikon
0
163
Member Avatar for srivardhanms

What is the difference between Definition and Declaration of a variable? Am not talking about function, but variable. When I googled, I found these two answers which are quite contradictory! While one says "definition occures once through the program( memory is allocated once ), but the declaration can occur many …

Member Avatar for srivardhanms
0
1K
Member Avatar for daniel.ngugi.980

please help me to write a code which includes a function for calculating the squareroot of a number without using the predefined functions in the function header............

Member Avatar for gregha04756
0
123
Member Avatar for Potgiesh

Hey guys i'm having a lil trouble with object serialization. student * s = new student("Mike",200014); ofstream ofs("student.dat",ios_base::out | ios_base::binary); ofs.write((char*)&s,sizeof(s)); ofs.close(); If student was a class with attributes `studentName:string` and `studentNumber:int` would the above code write the object pointed by s to the file `student.dat` ?

Member Avatar for rubberman
0
208

The End.