You can use something like this:
while ((c = getc(fp)) != EOF)
if(c == 32) ....
You can use something like this:
while ((c = getc(fp)) != EOF)
if(c == 32) ....
If I understand your question, you want to send your local file names to server and then server read them and calculate the response.
When you send your request to server (HTTP-GET), the server is not able to read your local files. You need to send files binary data to server instead of their name. Or you need to put all your binary data to server web service application folder.
We don't provide code. If you have any problems post your code and people will help you. But for now and your start point and for the last time:
for(int iIndex = 1; iIndex<=100; iIndex++)
{
cout << iIndex << endl;
if( iIndex%5==0 )
cout << endl;
}
Maybe you could use somthing like this:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define RESULT_FAILURE -1
#define RESULT_SUCCESS 0
int16_t fun(char *iaddr)
{
char* p = NULL;
int i = 0;
int len = 0;
int rc = RESULT_SUCCESS;
if(strlen(iaddr)>0)
{
len = strlen(iaddr)+1;
p = (char*)malloc(len );
strcpy(p,iaddr);
for(i=0;i<len;i++)
{
printf("%c", p[i]);
}
free(p);
}
else
{
rc = RESULT_FAILURE;
}
return rc;
}
int main()
{
int rc;
rc= fun("10.3.28");
printf("irc=%d",rc);
return 1;
}
You dont need last if else. instead just use else
...
...
else //4095++
{
volt = 10 ;
}
You also need to define result variable as a unsigned.
C is Case Sensitive it means you must use all variables, macros, functions, ets as is in decleration.
You also have to declare all variables before you are using them.
I recommend you to use Camel Notation in naming of everythings except macros.
In windows you need to know system programming for using mouse event.
Using puts() -- BRAVO!!! Finally someone who doesn't use printf() :o)
I think you are a good C programmer. A few persons are using puts in their code, but puts performance is better than printf.
We know. That doesn't alter the fact that it's non-standard and should not be used.
standart for what? Every compiler have own standart. some of them also compatible with ANSI but they have own libraries. Like Microsoft, Borland, Watcom,.....
Because you have to allocate a memory block for each pointer. Pointers as its name explain are variables those point to address of memory blocks, so when you declare a pointer it is not garantee to point to suitable area of system memory so you have to do that by yourself and use malloc or alloc for allocate a memory block. Also you can assign it address of another varibale like a1[100].
I did not do any HW for others. He tried and need help and I get him a way to know what is his wrong. There were several mistakes in his code and I do it for him.
This is working code on Watcom C/C++
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <math.h>
#include <string.h>
int iConvertString2Integer(char *string, int iIndex, int iIntegerValue);
int iString2Integer(char *string);
int main (void)
{
char string[512];
printf("Enter a string of integers: ");
scanf("%s\0", string);
printf("The integer entered is : %d\n", iString2Integer((char *)string));
system("PAUSE");
return 0;
}
int iString2Integer(char *string)
{
return iConvertString2Integer(string, strlen(string)-1, 0);
}
int iConvertString2Integer(char *string, int iIndex, int iIntegerValue)
{
if (*string=='\0' || !isdigit(*string))
{
return iIntegerValue;
}
else
{
iIntegerValue += (*string-'0') * ((int)pow( 10, iIndex ));
return iConvertString2Integer(string + 1, --iIndex, iIntegerValue);
}
}
As deceptikon said, a declaration of variable is saying to compiler "I will use a variable it is defined before and on another file."
I think it is stupid thing to use pointer to pointer in this case.
Line number 13 and 15: you have missed an "&"
See scanfAlso, there are some other things i would like to mention:
1) # include<conio.h> --> Not standard C header
2) void main() --> Should be int main
3) clrscr(); and getch(); : Again, not standard.
myk45 conio.h is header file of Turbo C and Borland C++. clrscr() and getch() also is in conio.h. Just FYI.
change your lines 5,6 as below:int s1[3],s2[3],s3[3],total[3],per[3],i; char name[3][20],pid[3][10];
and change line 31 as below:printf("\n Your Total of Marks is:%d",(total[i]=s1[i]+s2[i]+s3[i]));
#include <stdio.h>
is a precompiler command and said to compiler 'before starting to compile my file add stdio.h file to this line'
There are several precompiler commands and #include is one of them. stdio.h file name is header file and there are alot of header files.
You need to read a little more about pointers. For example in line 117 you attempt to create an new node by using emp variable before you were assigning any values to emp members. Because emp members (account structure) are pointer and you have to assign a variable.
Pointers are useful in C but dengerous. Be careful ;)
I recommend you to use binary file read write for POS applications. Create an array of WaiterInfo and re-write all data to file every time that fields changed. Dont append to file or something like that. In this way you must add to or delete from array then write whole array to file.
You need to write your own C# compiler. there are not any compiler in the market for this purpose.
I cant understand what is your problem because you could use multiple generics as you wrote above.
for example:
public class Node<K, T>
{
public K Key;
public T Item;
public Node<K, T> NextNode;
public Node()
{
Key = default(K);
Item = default(T);
NextNode = null;
}
public Node(K key, T item, Node<K, T> nextNode)
{
Key = key;
Item = item;
NextNode = nextNode;
}
}
public class LinkedList<K, T>
{
Node<K, T> m_Head;
public LinkedList()
{
m_Head = new Node<K, T>();
}
public void AddHead(K key, T item)
{
Node<K, T> newNode = new Node<K, T>(key, item, m_Head.NextNode);
m_Head.NextNode = newNode;
}
}
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
LinkedList<int, string> list = new LinkedList<int, string>();
list.AddHead(123, "Sample");
}
}
Yes you can create own event arguments. You need to create a class that inherited from EventArgs for example
using System;
namespace EventExample
{
public class ShipArgs : EventArgs
{
private string message;
public ShipArgs(string message)
{
this.message = message;
}
// This is a straightforward implementation for
// declaring a public field
public string Message
{
get
{
return message;
}
}
}
}
If you want that your WinForm application react as a web service server first you have to write TCP/IP server then implement one of web service protocols you want to use, usually SOAP. For more information about protocols Click Here
Just call the method that defined for button event into timer event method.
private void timer1_Tick(object sender, EventArgs e)
{
button1_Click( sender, e);
}
you also could put null for parameters.
private void timer1_Tick(object sender, EventArgs e)
{
button1_Click( null, null);
}
If there is a loop and you try to change ProgressBar value from this loop you have to check is your ProgressBar in the same thread of loop is working. (Use InvokeRequired and if it is true Invoke the method)
I recommend you dont change the value of a ProgressBar or any other controls within a thread. Instead rise an custom event.
As it seems you have control of both the called method and the UserControl override that calls the method you can choose where to do the error handling.
Remember that when a handler is called the Object sender parameter is the control that raised the event, so you could update the control state in the handler routine rather than in the controls event override.
private void textBox_TextChanged(object sender, EventArgs e) { var textbox = sender as TextBox; if (textbox == null) return; // do something with textbox. }
Or you could pass your own event args object (derived from the EventArgs object required for the handler).
// Your own custom EventArgs class (must derive from the class needed for the event called) public class MyTextEventArgs : EventArgs { public bool OK { get; set; } } //Event override in UserControl protected override void OnTextChanged(EventArgs e) { var args = new MyTextEventArgs(); base.OnTextChanged(args); if (args.OK) { // do something } } // Event handler function that returns a value using custom EventArgs private void textBox_TextChanged(object sender, EventArgs e) { var args = e as MyTextEventArgs; if (args == null) return; args.OK = true; // or false }
Thanks a lot dude ;)
This is what I am looking for ? :)
Thanks again
What determines success of the method?
If it is exceptions then just put a try-catch around the base.OnClick(..).Something like this:
bool callOK = true; try { base.OnClick(xEventArgs); } catch { callOK = false; } if (callOK) ChangeStateOfControl();
Thank you. I can throw an exception in method. But is there any other way?
Most 'Events' don't return a value.
If they do, then it is via the EventArgs object.
E.g. Cancel property of a CancelEventArgs object.Exception handling should be done in the called routine. (i.e. in vExitApplication)
If this does not answer your question then please explain better what you mean by:
"I cant recognize the result of assigned function within control."
I have access to EventArgs in method but I want to know what happen in method in control.
I assign methods (function I am old C programmer so sometimes I am using the old worlds :) ) to event handler of control and want to know what happen in method but in control not outside of the controls. Because all these methods are defined outside of the controls and all of them can use the same methods if conditions is proper.
What, exactly, do you want to have happen. Does the method run on that event? Is it supposed to change the state of the control? Does it change the state of the control? Does the control reflect the changed state?
I assigned a method to (for example) Click event handler then I want to know what happen in that method. I overrode the OnClick and want to change the state of control if method is succeeded. if not the state must not be changed.
protected override void OnClick(EventArgs xEventArgs)
{
base.OnClick(xEventArgs);
if( bOkTheAction==true)
{
ChangeStateOfControl();
}
}
Hi folks,
I am working on a Windows Form project that all things in it are dynamically created during run time.
So all controls are created during running application and also events are assigned to controls. Also I have to mention all controls are user defined controls.
All event functions are already written and during run time just I assign them to proper control event handler as usual:
sampleButton.Click += new System.EventHandler(vExitApplication);
My problem is I cant recognize the result of assigned function within control. Is there any method to understand what is that function result for example is there any exception or not?
Thanks
Dear Epmpror, please put your own code so we will say you what is going wrong. This is not a forum for solving your homework. We just help you for your improvment. By the way you could look at this http://www.daniweb.com/forums/thread43314.html
use this code for "localhost"
using System.Web.Mail;
.
.
.
MailMessage xMailMessage = new MailMessage();
xMailMessage.From = "My Test System <test@test.com>";
xMailMessage.To = "vatoovatoo@mousavi.net";
xMailMessage.Subject = "This is a test";
xMailMessage.BodyFormat = MailFormat.Html;
xMailMessage.Body = "<html><head><title>Test emial</title></head><br /><br /><hr>JUST A TEST<hr><br /><br /></body></html>";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(xMailMessage);
.
.
.
As I understand this is not a recursive problem because
F(1) is not defined. Also I cant find any
F(a) = F(a+n) is not possible
so this is not recursive.
as I know GloMoSim software does not have C/C like developing environment.
buddy you are in wrong place
i work in OFFOK Company
Hey there buddy, welcome to Daniweb. :D
I know alittle Arabic but not enough. I recommend that your company also put an English page for people like me ;) As I understand (maybe I am wrong) you are distributing Islamic Softwares :)
You could use sprintf to convert int numbers to string then compare them with strcmp or memcmp
if you want do run a loop at least once, it is better to use do-while loop.
lets explain more. look this sample code:
FILE *fp;
do
{
read file and assign some values
}
while( some data in file is equal to special value so file read again );
will use last data from file
in this example if you dont use do-while loop structure you need read file once before loop and also read in loop ;)
as you say "it is mainly just a readability thing"
if you want do run a loop at least once, it is better to use do-while loop.
lets explain more. look this sample code:
FILE *fp;
do
{
read file and assign some values
}
while( some data in file is equal to special value so file read again );
will use last data from file
in this example if you dont use do-while loop structure you need file once before loop and also read in loop ;)
as you say "it is mainly just a readability thing"
I did some correction to your code and now it is working ;)
Your fault was in set next node address in linked lists
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#define FIRSTCLASS 0x01
#define ECONOMYCLASS 0x02
#define FIRSTSEATS 40
#define ECONOMYSEATS 40
#define SEATSIZE (FIRSTSEATS+ECONOMYSEATS)
#define LENGTH 25
typedef struct BPassStruct
{
int classType;
int seat;
char firstname[SEATSIZE];
char lastname[SEATSIZE];
} bPass;
typedef struct NodeStruct
{
bPass data;
struct NodeStruct *next;
} node;
/* function prototypes */
void askFlight( int,int[], node * );
void askName( int, node * );
void printBPass( node * );
void printHeading( void );
void chkFClass( int, int, int, int, int[], node * );
void chkEClass( int, int, int, int, int[], node * );
void prFlight( node *headNode, int seatnumber, int seat[]);
int main(void)
{
int seatnumber = 0; /* passenger seat number */
int seat[SEATSIZE] = {0}; /* array to verify seats availible */
int choice = 0;
node *headNode = NULL;
node *newNode;
node *currentNode;
do
{
newNode = (node *)malloc( sizeof( node ) );
askFlight( choice, seat, newNode ); /* prompt user to choose flight */
newNode->next = headNode;
headNode = newNode;
puts( "\nWould you like to board another flight?" ); /* prompt user to choose to board flight */
scanf( "%*c%c", &choice ); /* read in choice */
}
while( choice == 'y' || choice == 'Y' );
if( choice=='n' || choice=='N' ) /* if choice = no print plane roster */
{
prFlight( headNode, seatnumber, seat );
currentNode = …
you also can convert HEX number to string then convert them to decimal or integer again.
I mean
sprintf( tmp, "%02X%02X", TH1, TL1 );
sscanf( tmp, "%X", &intHex );
this is a second way to do this but jephthah's post is better ;)
I w'd like tom Download Turbo C (window version). Can any one sugget any site,
thank in advance :confused:
I think this is a little late for you but maybe some other people want to download ;)
try this link http://forum.mousavi.net/showthread.php?t=3
But this is not a C problem. This is just a math. question.
where you set the "ptr_size" value. Meybe it is equal to 50 ;)