114 Posted Topics
Re: [QUOTE=guidely;1664174]Hi, How to read line by line of text file and store to array C data.txt example [CODE] 1234 25500 24000 1 1345 23523 21209 5 9865 12389 600 98 .... [/CODE] and sorted in order by last column I try everything and it not working Thank[/QUOTE] Well, Can you … | |
Re: [QUOTE]thanks. after i put the printing code, what should i do to get the number of the byte that the program should display?[/QUOTE] If you mean to take a single digit(i.e. the user will be able to enter at most nine characters only). then here's how : [CODE]get_limit: mov ah,01h … | |
Re: I think the problem was the [ICODE]scanf[/ICODE] function you were using to read the floating point number.[ICODE]scanf[/ICODE] becomes a little bit upset if it doesn't get what it wants.Also use fgets instead of gets if you want to avoid another "segmentation fault" error. [CODE]#include <stdio.h> #include <stdlib.h> typedef struct cricket{ … | |
Re: [QUOTE=fullarmorzz;1661637]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?[/QUOTE] You mean like this : [CODE]for (a=0;a<5;a++){ for (j=0;j<5;j++) printf("%d\t",x[a][j]); printf("\n"); } [/CODE] | |
Re: [QUOTE]&& is more flexible than &[/QUOTE] You think so? [CODE]Which one is better?[/CODE] Gosh, I don't know that one.But what I know (up until now) is, those are two different things(though their result may coincide sometimes).The '&' operator is a 'bitwise operator' and returns the result of the operation between … | |
Re: I think you're highly mistaken about how functions work. 1.Why are you declaring all the variables as global ? 2.The compiler isn't your math teacher: [CODE]x=2(x1+x2); y=2(y1+y2);[/CODE] you should explicitly tell the compiler what to do(use '*' operator): [CODE]x=2*(x1+x2); y=2*(y1+y2);[/CODE] The brackets in c are either used to override the … ![]() | |
Re: [QUOTE=theCompiler;1660447]i will plot 3 points[/QUOTE] Here are some links that might help you. [URL="http://www.mycplus.com/tutorials/c-programming-tutorials/graphics-programming/"]http://www.mycplus.com/tutorials/c-programming-tutorials/graphics-programming/[/URL] [URL="http://electrosofts.com/cgraphics/"]http://electrosofts.com/cgraphics/[/URL] [URL="http://www.programmingsimplified.com/c-graphics-programming-tutorial"]http://www.programmingsimplified.com/c-graphics-programming-tutorial[/URL] | |
Re: The problem is that you're calling the functions "getPoint" and "continueCraps" with either no arguments at all [CODE] getPoint(); // find the point ... continueCraps();[/CODE] or insufficient number of arguments. [CODE]int point = getPoint(myPoint); // the point is myPoint[/CODE] See your declarations for these functions [CODE]int getPoint(int myPoint, int Balance, … | |
Re: [QUOTE=110722] Hey guys, there is an error in this code in fact after encrypting the sentence, i wanted the program to ask if "You want to try again", but i don't know its running the program again without asking the user to input the sentence first and its outputting the … | |
Re: %u is a format specifier for an unsigned integer used in printf and scanf. | |
Re: [QUOTE=meli123;1659312]it works perfectly..I just want to understand the logic of how its doing it, specifically: [CODE]for(int i = inp.length()-1, j = 0; i >= 0; i--, ++j) dec += (inp[i]-48) * pow((float)base-48, j);[/CODE][/QUOTE] Here, i= the digit from lower place value to higher place value(initially i=digit in ones' place) j= … | |
Re: [QUOTE=phileyofish;1659241]Can you give me an example of what would work for step 4? I don't really understand.[/QUOTE] Well, first check if the number is divisible by 2.[QUOTE=Momerath]as if it isn't divisible by 2, it's not divisible by any other even number. [/QUOTE] So, [CODE]#include <math.h>//sqrt is defined here. if(onenumber%2!=0){ for(count=3;count<=sqrt(onenumber);count+2){//the … | |
Re: [QUOTE=niyasc;1658287]I'm using this code to initialize b pointer *(b+n)=(char *)malloc(sizeof(char)*20); [/QUOTE] That's not called initializing ,it's called dereferencing of b.Dereferencing a pointer always involves the value present at the address pointed to by that pointer. for e.g. If there's a pointer 'ptr' to char [CODE]char letter1='A']; char *ptr;[/CODE] Then you … | |
Re: [QUOTE=Shodow;1658184]my bad help me convert cout to printf and cin to scanf.. help me pls asap[/QUOTE] here you go: [CODE]int printf(const char *format, ...)[/CODE] 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: [CODE]printf("Hello, … | |
Re: 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 … | |
Re: function [ICODE]stdout[/ICODE] prints the string in to the console, so you have to "assemble" (not compile)as a console program to produce an output from the above code. If you want to "make" a message box then you have to invoke the [ICODE]MessageBox[/ICODE] funtion(In that case don't forget to include "user32.inc" … | |
Re: [QUOTE]how am i supposed to draw a big perpendicular line ?[/QUOTE] Perpendicular to what? [QUOTE]is it possible to draw a perpendicular line ? [/QUOTE] Drawing a perpendicular line is no different than drawing a simple line like you have drawn above. | |
Re: [QUOTE]1) What do I need in a function to take a whole word?[/QUOTE] using getchar() , you're gonna have to put it in a loop, like this: [CODE]while((c=getchar())!=EOF)[/CODE] and save it to an array to form the complete word. [QUOTE]2) How do I print each word in a new line? … | |
Re: [QUOTE=reojavier;1655303]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.[/QUOTE] Nobody's gonna provide you a full working code for you, you should write it yourself.This site does help those … | |
Re: [QUOTE=deva89;1655288]Actually i am trying to create some patterns using loop like pascal's triangle etc. But the concept of loop is still not very clear to me as i am learning c language myself without any professional help. would anyone please elaborate me with the help of an example and explain … | |
Re: since [ICODE]fgets[/ICODE] will not do what you're trying to do: [QUOTE][CODE]while(fgets(inarray,sizeof(inarray),stdin) !=NULL)[/CODE][/QUOTE] Because [ICODE]fgets[/ICODE] 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 [ICODE]getchar()[/ICODE], … | |
Re: First of all, you're using the if statement in the wrong way(a semicolon before the body) [QUOTE][CODE]if (t != NULL); { printf("%s\n",line);// here you should use "t" instead of "line" }[/CODE][/QUOTE] Strtok separates the string in tokens separated by a delimiter string (here " "). Printing the "t" will print … | |
Re: From your question above I only managed to understand that, you want to display all the files with '.c' and '.txt' extensions in the current directory . Am I right? if so then you can do like this in bash: [CODE]ls *.c *.txt [/CODE] i.e [I]ls[/I] [I]filetypes[/I]. '*' is just … | |
Re: As Gerard said earlier ,[QUOTE]Once it reaches 127(the character variable) the value will wrap around to the lowest values which is -128.[/QUOTE] so this will happen with your code. when i becomes127 (for the first time); [CODE]while(i<=127)[/CODE]since it satisfies the loop. will go inside and prints the value of i(=127).[CODE]printf("%d\n",i);[/CODE] … | |
Re: [QUOTE]I AM USING TURBO C To Write This Programe [/QUOTE] I think You should get another compiler, may be [URL="http://www.pellesc.de/"]pelles C[/URL] or [URL="http://www.codeblocks.org/"]Code::Blocks[/URL] or [URL="http://www.google.com/search?q=free+c+compilers"]any other[/URL], whichever you like and feel comfortable to use. [QUOTE]@gerard4143 sir i am a starter pizz make it correct [/QUOTE] If you're a starter ,IMHO … | |
Re: [QUOTE=fullarmorzz;1650538][CODE] #include<stdio.h> #include<conio.h> main() { int a,b,c,d,e,f,g,h,i,j,sume,sumo; printf("Enter 10 integers: \n"); scanf("%d%d%d%d%d%d%d%d%d%d",&a,&b,&c,&d,&e,&f,&g,&h,&i,&j); [/CODE] I had written this far. I really do not know what to do next about only adding the inputted odd or even integers. :D I thank you for not giving the code and teaching me. modulus? really? … | |
Re: You should post it in[URL="http://www.daniweb.com/software-development/python/114"] the python forum [/URL] and yes try to be explicit about your problem(even including your code if you have to), that way you'll get what you're looking for much faster. | |
Re: You'd better post shell scripting related kind of threads [URL="http://www.daniweb.com/software-development/shell-scripting/113"]here[/URL] any way ,you can edit it like this [CODE]cat > file.txt Hello, I am a linux user myself. EOF[/CODE] and press [ctrl]+[c] keys to save it. And if you want to use c for that purpose.then [CODE]#include <stdio.h> int main(){ … | |
Re: Obviously because you're reading each string from the file saving into a variable and printing newline('\n') after each one.[CODE]printf("%s\n",name);[/CODE] Don't you think this : [CODE]if(feof(fp)) break;[/CODE] is unnecessary since the [ICODE]while [/ICODE]statement already checks the condition and in addition it's preventing the last string from being printed out. Also don't … | |
Re: Sure.one way to do it is, put the whole program in an infinite loop and ask the user each time whether to continue or not. Check the user's answer if yes loop back else end the loop and exit. | |
Re: of course you can. [CODE]Addsign db '+','$'[/CODE] or [CODE]Addsign db 2Bh[/CODE] --> 2Bh being hex value of '+' in ascii character set. In this way: char ascii(hex) '-'----->2Dh '*' ---->2Ah '/'----->2Fh | |
Re: [URL="http://www.daniweb.com/software-development/c/threads/265050"]This[/URL] thread might clear things up. | |
Re: First of all ,put your code between the code tags (see that "[CODE]" thing just above your message editor box), it'll make easier to read for all of us and even you. [CODE] #include <stdio.h> int main(void) { //your code return 0; }[/CODE] use while instead of [CODE]do while[/CODE] and … | |
Re: There are tons of syntax errors here. Did you try to compile your code? 1.You have not [I]#include[/I]d stdlib.h file(system() is defined in stdlib.h). Are you using that to clear the screen? I think you should avoid doing that.As [URL="http://www.daniweb.com/software-development/cpp/threads/172612"]some people[/URL] say, you have no right to own the console. … | |
Re: [QUOTE=dev90;1647979]thnx...bt then why we take & while using integer type of array?[/QUOTE] consider example given by [B]asitmahato[/B]. [QUOTE][CODE]int b[10] scanf("%d",b);//b is also the base address of the array .[/CODE][/QUOTE] It is same as writing: [CODE]int b[10] scanf("%d",&b);//gives 'address of' b,(the zeroth place) printf("%d\n",*(arr));//prints the 'value at address" zero of array … | |
I wrote a procedure to read integers(unsigned) from stdin and store it in a variable. I wanted it to handle backspaces too. so I made some adjustments but unfortunately it didn't work.--see line 14 in the code [CODE]get_num: ;(function get_num: read integers from stdin) push ax ;save all registers push … | |
Alright, here's the deal.There's a folder with Jpg images and I want to open each JPG image in that folder, rotate it clockwise once and save it with the same name in the same folder. How do I do that with batch programming? We Can't use "Windows Picture and Fax … | |
[CODE] .MODEL small .STACK 100h ; defines a stack 100h (256) bytes long .DATA String DB "Hello World!",'$' ; variable declaration .CODE Start: mov dx,offset String ; point dx to the storage location for the first character mov ah,9 ; dos function for string output int 21h Stop: mov ax,4C00h … | |
I'm Using [ICODE]fwrite[/ICODE] to print the contents of a sturcture in a file. [CODE] #include <stdio.h> #include <stdlib.h> struct com{ int code; char* name; }; int main() { struct com py[2]={{21,"Monty Python"}, {22,"Python lang"} }; FILE * fp; if((fp=fopen("data.txt","w+"))==NULL) exit(1); fwrite(&py,sizeof(struct com),1,fp); /*int i; for(i=0;i<2;i++) fprintf(fp,"code:%d,name:%s\n",py[i].code,py[i].name); */ fclose(fp); return 0; … | |
I am trying to write a program for searching strings(one at a time)in a text file. To start things off, I wrote this one. [CODE] #include <stdio.h> #include <string.h> #include <stdlib.h> #include <ctype.h> int main() { FILE *txt_file; int chr;/*char read by fgetc*/ int word_match=0; const char* substring ="window";/*search word*/ … | |
Here's a code to find out if the number is palindrome or not. [CODE] #include <stdio.h> int main() { int num,chknum1,chknum2=0,i,rmndr;/*here rmndr is remainder after mod,chknum is reversed num*/ printf("enter the number"); scanf("%d",&num); chknum1=num;/*saving num,since it is manipulated*/ for(i=0;i<=sizeof(chknum1);i++) { rmndr=num%10; num=num/10; chknum2=chknum2*10+rmndr; } printf("chknum1 %d,chknum2 %d",chknum1,chknum2); //if(chknum1=chknum2) //printf("Is palindrome"); … | |
[CODE] #include <stdio.h> float pows(float,float); int main() { float num,base; printf("enter base followed by power integer."); scanf("%f %f",&base,&num); printf("%f ",pows(base,num)); return 0; } float pows(float base,float n) { if(n==0) return(1); else if(base==0) return(0); else for(;n>=1;n--) { return(base*pows(base,n-1));/*recursive*/ } } [/CODE] | |
I'm trying to embed python script in c in windows. [CODE] #include <Python.h> int main(int argc, char *argv[]) { Py_Initialize(); PyRun_SimpleString("from time import time,ctime\n" "print 'Today is',ctime(time())\n"); Py_Finalize(); return 0; } [/CODE] from the python documentation. I'm compiling with Microsoft's lcc. I'm getting following errors. Error c:\lcc\examples\python\pyembed.c 7 undefined reference … | |
I'm trying to convert hexadecimal values to Binary. I've done Decimal values to Binary up to 32 bits in this way: [CODE] #include <stdio.h> int showbits(int);/**************function*prototype******************************/ int main() { unsigned int num; printf("enter the number."); scanf("%d",&num); printf("%d in binary is ",num); printf("\n"); showbits(num);/*********************function*call********************************/ return 0; } showbits (int n)/******************function*definition****************************/ //* … | |
Re: Or You may not have specified your Include directories. for example C:\TC\INCLUDE | |
I've been trying to automate the creation of a user account with admin rights using cmd bat . [CODE] net localgroup administrators [I]account name[/I]/add [/CODE] got the following error: [CODE]There is no such global user or group:[I]account name[/I][/CODE] what's the problem? | |
I couldn't find a decent C network programming book for windows. Can anybody help me? | |
I want to run a program every time windows starts with a certain user's credentials . If i did that in bat file ,it will prompt for the user's password.How can i automate the insertion of password? | |
make failed Error: Error: Unresolved external '_main' referenced from C:\BC5\LIB\C0X32.OBJ I got above error when trying to build one of the examples given in \BC5\examples directory.What is the cause? | |
Re: 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. |
The End.