Search Results

Search found 278 results on 12 pages for 'scanf'.

Page 7/12 | < Previous Page | 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Indexing with pointer C/C++

    - by Leavenotrace
    Hey I'm trying to write a program to carry out newtons method and find the roots of the equation exp(-x)-(x^2)+3. It works in so far as finding the root, but I also want it to print out the root after each iteration but I can't get it to work, Could anyone point out my mistake I think its something to do with my indexing? Thanks a million :) #include <stdio.h> #include <math.h> #include <malloc.h> //Define Functions: double evalf(double x) { double answer=exp(-x)-(x*x)+3; return(answer); } double evalfprime(double x) { double answer=-exp(-x)-2*x; return(answer); } double *newton(double initialrt,double accuracy,double *data) { double root[102]; data=root; int maxit = 0; root[0] = initialrt; for (int i=1;i<102;i++) { *(data+i)=*(data+i-1)-evalf(*(data+i-1))/evalfprime(*(data+i-1)); if(fabs(*(data+i)-*(data+i-1))<accuracy) { maxit=i; break; } maxit=i; } if((maxit+1==102)&&(fabs(*(data+maxit)-*(data+maxit-1))>accuracy)) { printf("\nMax iteration reached, method terminated"); } else { printf("\nMethod successful"); printf("\nNumber of iterations: %d\nRoot Estimate: %lf\n",maxit+1,*(data+maxit)); } return(data); } int main() { double root,accuracy; double *data=(double*)malloc(sizeof(double)*102); printf("NEWTONS METHOD PROGRAMME:\nEquation: f(x)=exp(-x)-x^2+3=0\nMax No iterations=100\n\nEnter initial root estimate\n>> "); scanf("%lf",&root); _flushall(); printf("\nEnter accuracy required:\n>>"); scanf("%lf",&accuracy); *data= *newton(root,accuracy,data); printf("Iteration Root Error\n "); printf("%d %lf \n", 0,*(data)); for(int i=1;i<102;i++) { printf("%d %5.5lf %5.5lf\n", i,*(data+i),*(data+i)-*(data+i-1)); if(*(data+i*sizeof(double))-*(data+i*sizeof(double)-1)==0) { break; } } getchar(); getchar(); free(data); return(0); }

    Read the article

  • Telephone Directory

    - by Mizukage of Meron 5
    I need your help. We are ask to make a telephone directory program that asks your name, address, and telephone number. If the name you entered already exists, it will display that it already exists. This is what i have so far... #include<stdio.h> #include<conio.h> struct file { char name[25],address[25]; double telno; }; char tempname[25],tempadd[25]; double tempnum; int x; int choice; FILE *fp; main() { struct file rec; clrscr(); fp=fopen("TelDir.txt","a+"); while(!feof(fp)) { fscanf(fp,"%s %s %.0lf,&tempname,&tempadd,&tempnum); printf("\n%s\t\t%s\t\t\t%.0lf",tempname,tempadd,tempnum); printf("\nEnter Name: "); gets(rec.name); if(strcmp(rec.name,tempname)==1) { printf("\n\nALREADY EXIST!"); printf("\n%s\t\t%s\t\t\t%.0lf",tempname,tempadd,tempnum); getch(); } else { printf("Enter Address: "); scanf("%s",&rec.address); printf("Enter your Telephone No.: "); scanf("%lf",&rec.telno); printf("%s\t\t%s\t\t%\t\t0lf",rec.name,rec.address,rec.telno); fprintf(fp,"%s %s %.0lf\n",rec.name,rec.address,rec.telno); } } fclose(fp); getch(); } But this thing doesn't work. I don't know where the error is. Can someone help me on this? I would really appreciate if you could help me somehow.

    Read the article

  • C to C++ Conversion [closed]

    - by Annalyne
    Can someone convert this code to C++, pretty please? :( #include <stdio.h> #include <stdlib.h> #include <time.h> #define WEAPON_ROPE 10 #define WEAPON_REVOLVER 20 #define WEAPON_LEADPIPE 30 #define WEAPON_CANDLESTICK 40 #define WEAPON_KNIFE 50 #define WEAPON_WRENCH 60 #define PEOPLE_MRGREEN 100 #define PEOPLE_MSSCARLET 200 #define PEOPLE_CONLMUSTARD 300 #define PEOPLE_PROFPLUM 400 #define PEOPLE_MISPEACOCK 500 #define PEOPLE_MISWHITE 600 #define PLACE_KITCHEN 1 #define PLACE_HALL 2 #define PLACE_POOLROOM 3 #define PLACE_STUDY 4 #define PLACE_LOUNG 5 #define PLACE_LIBRARY 6 #define PLACE_CONSERVATORY 7 #define PLACE_DINING 8 #define PLACE_BILLIARDS 9 int main() { int die = 0; int players[6][9] = {{0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}, {0, 0, 0, 0, 0, 0}}; int allCards[] = {WEAPON_ROPE, WEAPON_REVOLVER, WEAPON_LEADPIPE, WEAPON_CANDLESTICK, WEAPON_CANDLESTICK, WEAPON_KNIFE, WEAPON_WRENCH, PEOPLE_MRGREEN, PEOPLE_MSSCARLET, PEOPLE_CONLMUSTARD, PEOPLE_CONLMUSTARD, PEOPLE_PROFPLUM, PEOPLE_MISPEACOCK, PEOPLE_MISWHITE, PLACE_KITCHEN, PLACE_HALL, PLACE_POOLROOM, PLACE_STUDY, PLACE_LOUNG, PLACE_LIBRARY, PLACE_CONSERVATORY, PLACE_DINING, PLACE_BILLIARDS}; int deckSize = 23; // number of cards in allCards array int count; for (count = 0; count < deckSize; ++count) { printf(", %d", allCards[count]); } // End for // These three array's are so you can put a card back, if need be... int weaponCards[] = {WEAPON_ROPE, WEAPON_REVOLVER, WEAPON_LEADPIPE, WEAPON_CANDLESTICK, WEAPON_CANDLESTICK, WEAPON_KNIFE, WEAPON_WRENCH}; int weaponDeckSize = 7; int peopleCards[] = {PEOPLE_MRGREEN, PEOPLE_MSSCARLET, PEOPLE_CONLMUSTARD, PEOPLE_CONLMUSTARD, PEOPLE_PROFPLUM, PEOPLE_MISPEACOCK, PEOPLE_MISWHITE}; int peopleDeckSize = 7; int placeCards[] = {PLACE_KITCHEN, PLACE_HALL, PLACE_POOLROOM, PLACE_STUDY, PLACE_LOUNG, PLACE_LIBRARY, PLACE_CONSERVATORY, PLACE_DINING, PLACE_BILLIARDS}; int placeDeckSize = 9; srand(clock()); // seed rand() using clock() which gives // the current tick your processor is at... int killer[3]; // no need to initialize yet. killer[0-2] will initialize int deckShuffle = rand() % weaponDeckSize; // picks one number out of the deck killer[0] = weaponCards[deckShuffle]; allCards[deckShuffle] = 0; // Card drawn. No longer exists in deck deckShuffle = rand() % peopleDeckSize; // picks another random card out of the deck killer[1] = peopleCards[deckShuffle]; allCards[deckShuffle + weaponDeckSize] = 0; // Card drawn. No longer exists in deck deckShuffle = rand() % placeDeckSize; // randomly picks the last card needed killer[2] = placeCards[deckShuffle]; allCards[deckShuffle + weaponDeckSize + peopleDeckSize] = 0; // Card drawn. No longer exists in deck int numberOfCards = 0; printf("CLUE\n"); printf("written by John Schintone\n"); printf("Origonal game delvoped by Hasbro\n"); int numberOfPlayers = 0; while ((numberOfPlayers < 3) || (numberOfPlayers > 6)) { printf("How many players are Going to play :\n"); printf("[number] > "); scanf("%d",&numberOfPlayers); // A very fast if statement which only uses integers/char's switch(numberOfPlayers) { case 6: { numberOfCards = 3; } break; case 5: { numberOfCards = 4; } break; case 4: { numberOfCards = 5; } break; case 3: { numberOfCards = 6; } break; default: { printf("You must enter a number between 3 and 6...\n"); } // End default } // End switch } // End while int index1, index2; // Note: ++index1; is faster than index1++; and will almost always // produce better code (index1++ happens after this statement line. // ++index1 increments index1 before this statement line) for (index1 = 0; index1 < numberOfPlayers; ++index1) { printf("Player %d", index1); for (index2 = 0; index2 < numberOfCards; ++index2) { // Remember that allCards[deckShuffle] == 0 because we removed that // card ages ago... works out well, just don't forget you did that : ) while (allCards[deckShuffle] == 0) { deckShuffle = rand() % deckSize; } // End while players[index1][index2] = allCards[deckShuffle]; allCards[deckShuffle] = 0; // Card removed for after loop... printf(", %d", players[index1][index2]); switch(players[index1][index2]) { case WEAPON_ROPE: { } break; // Add more... case PEOPLE_MRGREEN: { } break; // Add more... case PLACE_KITCHEN: { } break; // Add more... default: { printf("Program has caught player %d cheating...", index1); } // End default } // End switch } // End for printf("\n"); } // End for printf("The killer is %d, with the %d, and in the %d \n\n", killer[0], killer[1], killer[2]); printf("Type h for this help... \n"); printf("Type e to escape... \n"); printf("Type r to roll the die... \n"); char command = '\0'; // \0 represents zero, or the null character while (command != 'e') { printf("[one character] > "); scanf("%c", &command); if (command == 'r') { die = rand() % 6 + 1; printf("Your number is: %d \n", die); } // end while if (command == 'h') { printf("Type h for this help... \n"); printf("Type e to escape... \n"); printf("Type r to roll the die... \n"); } // End if printf("\n"); } // End while return(0); // Success. Program worked ok } // End main() Function

    Read the article

  • How to pass an IP address to inet_addr?

    - by November
    I can't seem to pass an IP address to inet_addr. I have gone through the debug but I still can't figure out why this won't work. printf("Server IP\nIP:"); scanf("%s",cmdPtr); //Bind socket address.sin_family = AF_INET; address.sin_addr.s_addr = inet_addr(&cmdPtr); address.sin_port = htonl(SERVER_PORT); lenC = sizeof(address); if (connect(sdC, (struct sockaddr *) &address , lenC) < 0) { perror("Could not bind Socket\n"); return -1; }

    Read the article

  • How to input 64-bit hex values in octave

    - by Chris Ashton
    I'm trying to use Octave as a programmer's calculator. I want to input a 64-bit pointer, but when I do apparently the 64-bit value gets silently truncated to 32-bit: octave:44> base_ptr=0x1010101020202020 base_ptr = 538976288 octave:45> uint64(base_ptr) ans = 538976288 octave:46> printf("%lx\n", base_ptr) 20202020 So it seems like it's truncated the input value to the low 32-bits. I would use scanf, but the docs say it should only be used internally. How can I input the full 64-bit value? Alternately, is there some awesome free programmer's calculator out there for Windows? (I know Windows calculator has a programmer's mode but I would like arbitrary variable support). I tried using my ti-89 but it also doesn't support 64-bit hex.

    Read the article

  • Binary Tree in C Insertion Error

    - by Paul
    I'm quite new to C and I'm trying to implement a Binary Tree in C which will store a number and a string and then print them off e.g. 1 : Bread 2 : WashingUpLiquid etc. The code I have so far is: #include <stdio.h> #include <stdlib.h> #define LENGTH 300 struct node { int data; char * definition; struct node *left; struct node *right; }; struct node *node_insert(struct node *p, int value, char * word); void print_preorder(struct node *p); int main(void) { int i = 0; int d = 0; char def[LENGTH]; struct node *root = NULL; for(i = 0; i < 2; i++) { printf("Please enter a number: \n"); scanf("%d", &d); printf("Please enter a definition for this word:\n"); scanf("%s", def); root = node_insert(root, d, def); printf("%s\n", def); } printf("preorder : "); print_preorder(root); printf("\n"); return 0; } struct node *node_insert(struct node *p, int value, char * word) { struct node *tmp_one = NULL; struct node *tmp_two = NULL; if(p == NULL) { p = (struct node *)malloc(sizeof(struct node)); p->data = value; p->definition = word; p->left = p->right = NULL; } else { tmp_one = p; while(tmp_one != NULL) { tmp_two = tmp_one; if(tmp_one->data > value) tmp_one = tmp_one->left; else tmp_one = tmp_one->right; } if(tmp_two->data > value) { tmp_two->left = (struct node *)malloc(sizeof(struct node)); tmp_two = tmp_two->left; tmp_two->data = value; tmp_two->definition = word; tmp_two->left = tmp_two->right = NULL; } else { tmp_two->right = (struct node *)malloc(sizeof(struct node)); tmp_two = tmp_two->right; tmp_two->data = value; tmp_two->definition = word; tmp_two->left = tmp_two->right = NULL; } } return(p); } void print_preorder(struct node *p) { if(p != NULL) { printf("%d : %s\n", p->data, p->definition); print_preorder(p->left); print_preorder(p->right); } } At the moment it seems to work for the ints but the description part only prints out for the last one entered. I assume it has something to do with pointers on the char array but I had no luck getting it to work. Any ideas or advice? Thanks

    Read the article

  • Problem using graphics.h in Ubuntu

    - by blooooomer
    # include<stdio.h> # include<graphics.h> # include<math.h> using namespace std; int main(void) { int gd=DETECT,gm; int r,x,y,p,xc=320,yc=240; initgraph(&gd,&gm,NULL); cleardevice(); printf("Enter the radius "); scanf("%d",&r); x=0; y=r; putpixel(xc+x,yc-y,1); p=3-(2*r); for(x=0;x<=y;x++) { if (p<0) { y=y; p=(p+(4*x)+6); } else { y=y-1; p=p+((4*(x-y)+10)); } putpixel(xc+x,yc-y,1); putpixel(xc-x,yc-y,2); putpixel(xc+x,yc+y,3); putpixel(xc-x,yc+y,4); putpixel(xc+y,yc-x,5); putpixel(xc-y,yc-x,6); putpixel(xc+y,yc+x,7); putpixel(xc-y,yc+x,8); } getch(); closegraph(); } installed graphics.h compiled using gcc filename.cpp -0 filename -lgraph then used ./filename the window apperared for 10 seconds and the error below appears: [xcb] Unknown sequence number while processing queue [xcb] Most likely this is a multi-threaded client and XInitThreads has not been called [xcb] Aborting, sorry about that. heart: ../../src/xcb_io.c:273: poll_for_event: Assertion `!xcb_xlib_threads_sequence_lost' failed. Aborted Any solutions?

    Read the article

  • Convert ieee 754 float to hex with c - printf

    - by Michael
    Ideally the following code would take a float in IEEE 754 representation and convert it into hexadecimal void convert() //gets the float input from user and turns it into hexadecimal { float f; printf("Enter float: "); scanf("%f", &f); printf("hex is %x", f); } I'm not too sure what's going wrong. It's converting the number into a hexadecimal number, but a very wrong one. 123.1443 gives 40000000 43.3 gives 60000000 8 gives 0 so it's doing something, I'm just not too sure what. Help would be appreciated

    Read the article

  • How do functional programming languages work?

    - by eSKay
    I was just reading this excellent post, and got some better understanding of what exactly object oriented programming is, how Java implements it in one extreme manner, and how functional programming languages are a contrast. What I was thinking is this: if functional programming languages cannot save any state, how do they do some simple stuff like reading input from a user (I mean how do they "store" it), or storing any data for that matter? For example - how would this simple C thing translate to any functional programming language, for example haskell? #include<stdio.h> int main() { int no; scanf("%d",&no); return 0; }

    Read the article

  • how to check if there is a division by zero in c

    - by user244775
    #include<stdio.h> void function(int); int main() { int x; printf("Enter x:"); scanf("%d", &x); function(x); return 0; } void function(int x) { float fx; fx=10/x; if(10 is divided by zero)// I dont know what to put here please help printf("division by zero is not allowed"); else printf("f(x) is: %.5f",fx); }

    Read the article

  • Something is wrong with this C code to reverse string, but I dont know what ? please help

    - by Harbhag
    Hi all, I am beginnner to programming. I wrote this little program to reverse a string. But if I try to reverse a string which is less than 5 characters long then it gives wrong output. I cant seem to find whats wrong. #include<stdio.h> #include<string.h> int main() { char test[50]; char rtest[50]; int i, j=0; printf("Enter string : "); scanf("%s", test); int max = strlen(test) - 1; for ( i = max; i>=0; i--) { rtest[j] = test[i]; j++; } printf("Reversal is : %s\n", rtest); return 0; }

    Read the article

  • Caesar's cipher in VC#

    - by purplepills
    #include<string.h> void main() { char name[50]; int i,j; printf("Enter the name:>"); scanf("%s",&name); j=strlen(name); for(i=0;i<j;i++) { name[i] = name[i]+3; } printf("ENCRYTED NAME=>%s",name); } This a caesar's cipher in c programming friends i want use this same thing in VC# where i will get input from user through textbox. please help me out.

    Read the article

  • Capture String from Array, C#

    - by Dan Snyder
    I'm trying to figure out how to get a string from an array starting at some given position. Say we have an array that's arbitrarily long and my string starts at location 1000. If I wanted to get a string from a file I would simply use something like getc or scanf or something. How do I carry out these same functions on an array instead of a file? *oh, keep in mind that the array is of type int and is full of numerical representations of ASCII characters.

    Read the article

  • Problem with the program!

    - by hopefulLLl
    Can you tell me what is the problem with this function. Can you help me to find the sum of digits of a number? #include<stdio.h> #include<math.h> void main() { int a,i=0,j=10,k,n=0,m; scanf("%d",&a); while((a%j!=0)&&i>=0) { m=pow(10,(i+1)); k=a%m; n=(a-(k*m)-n)/(m/10)+n; j=m*10; i++; } n=n+(n/(m/10)); printf("%d",n); } I need to use just the while loop... or the for loop! when i run it it shows"resumable processor fault"..help!

    Read the article

  • [C] this code, its work fine and return what i want, but its hangs before print it ??

    - by Rami Jarrar
    I make this program :: #include<stdio.h> char *raw_input(char *msg); main() { char *s; *s = *raw_input("Message Here Is: "); printf("Return Done.."); printf(s); } char *raw_input(char *msg){ char *d; printf("%s", msg); scanf("%s",&d); return d; } What this do is, it print my message and scan for input from the user, then print it,, but whats the problem in print the input from the user ??? Update:: I need the raw_input func. call be like this without any extra *s = *raw_input("Message Here"); I dont want to use this :: raw_input("Message Here Is: ", d); .... Just want to return the string that the user will enter .

    Read the article

  • How would you go about tackling this problem? [SOLVED in C++]

    - by incrediman
    Intro: EDIT: See solution at the bottom of this question (c++) I have a programming contest coming up in about half a week, and I've been prepping :) I found a bunch of questions from this canadian competition, they're great practice: http://cemc.math.uwaterloo.ca/contests/computing/2009/stage2/day1.pdf I'm looking at problem B ("Dinner"). Any idea where to start? I can't really think of anything besides the naive approach (ie. trying all permutations) which would take too long to be a valid answer. Btw, the language there says c++ and pascal I think, but i don't care what language you use - I mean really all I want is a hint as to the direction I should proceed in, and perhpas a short explanation to go along with it. It feels like I'm missing something obvious... Of course extended speculation is more than welcome, but I just wanted to clarify that I'm not looking for a full solution here :) Short version of the question: You have a binary string N of length 1-100 (in the question they use H's and G's instead of one's and 0's). You must remove all of the digits from it, in the least number of steps possible. In each step you may remove any number of adjacent digits so long as they are the same. That is, in each step you can remove any number of adjacent G's, or any number of adjacent H's, but you can't remove H's and G's in one step. Example: HHHGHHGHH Solution to the example: 1. HHGGHH (remove middle Hs) 2. HHHH (remove middle Gs) 3. Done (remove Hs) -->Would return '3' as the answer. Note that there can also be a limit placed on how large adjacent groups have to be when you remove them. For example it might say '2', and then you can't remove single digits (you'd have to remove pairs or larger groups at a time). Solution I took Mark Harrison's main algorithm, and Paradigm's grouping idea and used them to create the solution below. You can try it out on the official test cases if you want. //B.cpp //include debug messages? #define DEBUG false #include <iostream> #include <stdio.h> #include <vector> using namespace std; #define FOR(i,n) for (int i=0;i<n;i++) #define FROM(i,s,n) for (int i=s;i<n;i++) #define H 'H' #define G 'G' class String{ public: int num; char type; String(){ type=H; num=0; } String(char type){ this->type=type; num=1; } }; //n is the number of bits originally in the line //k is the minimum number of people you can remove at a time //moves is the counter used to determine how many moves we've made so far int n, k, moves; int main(){ /*Input from File*/ scanf("%d %d",&n,&k); char * buffer = new char[200]; scanf("%s",buffer); /*Process input into a vector*/ //the 'line' is a vector of 'String's (essentially contigious groups of identical 'bits') vector<String> line; line.push_back(String()); FOR(i,n){ //if the last String is of the correct type, simply increment its count if (line.back().type==buffer[i]) line.back().num++; //if the last String is of the wrong type but has a 0 count, correct its type and set its count to 1 else if (line.back().num==0){ line.back().type=buffer[i]; line.back().num=1; } //otherwise this is the beginning of a new group, so create the new group at the back with the correct type, and a count of 1 else{ line.push_back(String(buffer[i])); } } /*Geedily remove groups until there are at most two groups left*/ moves=0; int I;//the position of the best group to remove int bestNum;//the size of the newly connected group the removal of group I will create while (line.size()>2){ /*START DEBUG*/ if (DEBUG){ cout<<"\n"<<moves<<"\n----\n"; FOR(i,line.size()) printf("%d %c \n",line[i].num,line[i].type); cout<<"----\n"; } /*END DEBUG*/ I=1; bestNum=-1; FROM(i,1,line.size()-1){ if (line[i-1].num+line[i+1].num>bestNum && line[i].num>=k){ bestNum=line[i-1].num+line[i+1].num; I=i; } } //remove the chosen group, thus merging the two adjacent groups line[I-1].num+=line[I+1].num; line.erase(line.begin()+I);line.erase(line.begin()+I); moves++; } /*START DEBUG*/ if (DEBUG){ cout<<"\n"<<moves<<"\n----\n"; FOR(i,line.size()) printf("%d %c \n",line[i].num,line[i].type); cout<<"----\n"; cout<<"\n\nFinal Answer: "; } /*END DEBUG*/ /*Attempt the removal of the last two groups, and output the final result*/ if (line.size()==2 && line[0].num>=k && line[1].num>=k) cout<<moves+2;//success else if (line.size()==1 && line[0].num>=k) cout<<moves+1;//success else cout<<-1;//not everyone could dine. /*START DEBUG*/ if (DEBUG){ cout<<" moves."; } /*END DEBUG*/ }

    Read the article

  • [C] this code, its work fine and return what i want, but its hang before print it ??

    - by Rami Jarrar
    I make this program :: #include<stdio.h> char *raw_input(char *msg); main() { char *s; *s = *raw_input("Message Here Is: "); printf("Return Done.."); printf(s); } char *raw_input(char *msg){ char *d; printf("%s", msg); scanf("%s",&d); return d; } What this do is, it print my message and scan for input from the user, then print it,, but whats the problem in print the input from the user ???

    Read the article

  • problem with the programme!!

    - by hopefulLLl
    kindly tell me what is the pblm with this function wont it help me find the sum of digits of a number?? #include<stdio.h> #include(math.h) void main() { int a,i=0,j=10,k,n=0,m; scanf("%d",&a); while((a%j!=0)&&i>=0) { m=pow(10,(i+1)); k=a%m; n=(a-(k*m)-n)/(m/10)+n; j=m*10; i++; } n=n+(n/(m/10)); printf("%d",n); } i know the parenthesis used with math.h are nt right..what else is the pblm..i need to use just while loop..or the for loop!

    Read the article

  • Why do i get segfault at the end of the application after everything's been done properly ?

    - by VaioIsBorn
    #include <string.h> #include <stdlib.h> #include <stdio.h> int main(void) { unsigned char *stole; unsigned char pass[] = "m4ak47"; printf("Vnesi password: \t"); scanf("%s", stole); if(strncmp(stole, pass, sizeof(pass)) != 0) { printf("wrong password!\n"); exit(0); } else printf("Password correct\n"); printf("some stuf here...\n\n"); return 0; } This program is working nice, but with one problem - if the password is correct then it DOES do the printing of 'some stuf here...' but it also shows me segmentation fault error at the end. Why ?

    Read the article

  • segmentation fault

    - by gcc
    int num_arrays; char *p[20]; char tempc; int i=0; do { p[i]=malloc(sizeof(int)); scanf("%s",p[i]); tempc=p[i]; ++i; }while(tempc=='x'); num_arrays=atoi(p[0]); When i write num_arrays=atoi(..),gcc give me segmentation fault or memory stack is exceeded, I don't understand why it behaves like that can anyone explain, why?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12  | Next Page >