u not defined both variables ..
and on 169th line u allocating memory but u not holding its address ..
I think correct line there may be
guessWord = (char *) malloc ((sizeof(char)*2000)+1);
sry if its wrong not read your full program ..
u not defined both variables ..
and on 169th line u allocating memory but u not holding its address ..
I think correct line there may be
guessWord = (char *) malloc ((sizeof(char)*2000)+1);
sry if its wrong not read your full program ..
This may help u more
// Returns 1 if number or o if its strings
int isNumber(char num[])
{
int i = 0;
int flag = 1;
while(num[i])
{
if(!isNum(num[i])
{
flag = 0;
break;
}
i++;
}
return flag;
}
Scan String thn use a function like
int isNum(char c)
{
if ( c < '0' || c > '9' ) return -1;
return c - '0';
}
Function works for single char .. you may try for string ..
or else u can use same function for every char of the string and check return value for them all..
cut while loop from main and create menu() function paste it thr..
void menu()
{
while(1){
int opc;
printf("What u want to do?\n");
printf("1. smthing\n");
printf("2. smthing\n");
printf("Your Choice: ");
scanf("%d",&opc);
switch(opc)
{
case 1 : FirstFunction();
break;
case 2 : SecondFunction();
break;
..
..
..
default: printf("Wrong Choice\n");
break;
}
}
}
You can use a simple switch ..
May be like this..
#include <stdio.h>
int main(void){
while(1){
int opc;
printf("What u want to do?\n");
printf("1. smthing\n");
printf("2. smthing\n");
printf("Your Choice: ");
scanf("%d",&opc);
switch(opc)
{
case 1 : FirstFunction();
break;
case 2 : SecondFunction();
break;
..
..
..
default: printf("Wrong Choice\n");
break;
}
}
getchar();
}
#include "stdio.h"
main()
{
FILE *fsource, *fd;
char ch;
fsource = fopen("file_name", "r" ) ;
if ( fsource == NULL )
{
puts( "Cannot open source file" ) ;
exit(0);
}
fd = fopen ( "Destination", "w" ) ;
if( fd == NULL )
{
puts ( "Cannot open target file" ) ;
fclose ( fsource ) ;
exit( ) ;
}
while( (ch = fgetc(fsource)) != EOF )
{
fputc (ch,fd);
}
fclose(fsource) ;
fclose(fd);
}
It copies char by char from one file to another..
u can use
char *gets(char *line, int MAX , FILE *file);
int puts(char *line, FILE *file);
for reading array of char from a file n write that to other later..
Both are right ..
and
U cant use array names on left of the "=" ..
Its actually address of the first momory location allocated for the array not a variable name so u cant change that address .. Thats why the Lvalue error ..
All of us understands C language more easily .. Post part of code u coded so that everyone can get a clear idea what help you want..
oh ok ..
Hope your code working correctly now
Happy programming
i mean give options to user dude lk
printf("Enter your choice from following list");
printf("1 -> Add elements \n 2 -> smthing smthing etc");
Oopppssss ..
See in ur
for(i; i<(i+p); i++)
{
printf("Enter %d number:",i);
scanf("%d", &(*(a+i)));
}
i <(i+p)
when i increaments it increaments on either side..
Condition cant fail unless p=-i ..
Soluction is simple use another variable to store count of elements
int temp = i;
for(i; i<(temp+p); i++)
{
printf("Enter %d number:",i);
scanf("%d", &(*(a+i)));
}
and btw try to make program more user friendlier ..
Program works fine with scanf also but fflush(stdin) at 19 n 22 are must ..
I dont think thr are any special functions to do tht
but u can use older Borland C to change text size color them etc ..
Check graphics.h header ..